Converting 1Writer action

Hi there,

I’m looking how to convert this 1Writer script to Drafts 5. Everything I found doesn’t good for me. Anyone have any ideas?

Most of the editor methods are very similar between 1Writer and Drafts. I think the only difference in that script is the replace method…try:

let range = editor.getSelectedLineRange();
let s = editor.getTextInRange(range[0],range[1]);
let text = s + " = " + eval(s.replace(/\\/g,"Math."));
editor.setTextInRange(range[0],range[1], text);

Could you get me the work version of this Action? Thank you.