[I am desperate for HELP!] Modifying the code to also work on Rich Text Editor

I have a plugin that detects cursor position and text before it. However, it only works right now on multiline input. However, I also wish to have it work also in Rich Text Editor plugin. Can someone please give me advice please.

I hope someone could help as I am not much of a coder.

I can’t contact the previous developer and couldnt find a new one. This project has been stuck for months and I am desperate for help :frowning:

Below is the code:

function(properties, context) {
let i = 0;
let txt = properties.animation_text;
let ntxt = properties.normal_text;
let elementId = properties.element_id;
let speed = properties.animation_speed;
let cursorPostion = properties.cursor_position;
function applyTypewriterEffect() {
let initalContent = document.getElementById(elementId).value;
let input = document.getElementById(elementId);
if (i < txt.length && txt.length > 0 ) {
input.value = initalContent.slice(0, cursorPostion) + txt.charAt(i) + initalContent.slice(cursorPostion);
input.setSelectionRange(cursorPostion, cursorPostion)
if(ntxt !=null && ntxt !== ‘’ && i== txt.length && ntxt.length > 0)
input.value += ntxt;
setTimeout(applyTypewriterEffect, speed);
let selectionStart= properties.cursor_position;
let selectionEnd = properties.cursor_position + txt.length;
input.dispatchEvent(new Event(‘change’, { ‘bubbles’: true }));
setTimeout(function() {
if (input.setSelectionRange) {
input.setSelectionRange(selectionEnd, selectionEnd);
else if (input.createTextRange) {
var range = input.createTextRange();
range.moveEnd(‘character’, selectionEnd);
range.moveStart(‘character’, selectionEnd);

        }, 1000);



This topic was automatically closed after 70 days. New replies are no longer allowed.