JSFiddle - React, Tailwind, and code Playground

HTML

<label for="words">List of Words</label><br>
<textarea id="words"></textarea><br>
<button id="gen">Generate Ligatures</button><br>
<label for="ligs">Sorted Ligatures</label><br>
<textarea id="ligs"></textarea><br>
<label for="ligpairs">Sorted Ligature Pairs</label><br>
<textarea id="ligpairs"></textarea>

CSS

textarea {
    width: 300px;
    height: 120px;
    border: 3px solid #cccccc;
    padding: 5px;
    text-align: right;
    direction: rtl;
    overflow: auto;
}

JavaScript

function genLigs(words) {
    var nonjoiners = "ادڈذرڑزژوے";
    var ligatures = {};
    var ligpairs = {};
    for(i = 0; i < words.length; i++) {
        var ligs = [];
        var letters = words[i].split("");
        var lig = "";
        for(j = 0; j < letters.length; j++) {
            lig += letters[j];
            if(nonjoiners.indexOf(letters[j]) >= 0 || j == letters.length - 1) {
                ligs.push(lig);
                ligatures[lig] = ++ligatures[lig] || 1;
                lig = "";
            }
        }
        if(ligs.length > 1) {
            for(k = ligs.length - 1; k > 0; k--) {
                var pair = ligs[k-1] + ligs[k];
                ligpairs[pair] = ++ligpairs[pair] || 1;
            }
        }
    }
    return {"ligatures": ligatures, "ligpairs": ligpairs};
}

function init() {
    var words = document.getElementById("words").value.split(/\s+/);
    if(words[0] != "") {
        var res = genLigs(words);
        var ligatures = res["ligatures"];
        var sortedLigatures = Object.keys(ligatures).sort(function(a,b){return ligatures[b]-ligatures[a]});
        var ligpairs = res["ligpairs"];
        var sortedLigpairs = Object.keys(ligpairs).sort(function(a,b){return ligpairs[b]-ligpairs[a]});
        document.getElementById("ligs").value = sortedLigatures.join("\n");
        document.getElementById("ligpairs").value = sortedLigpairs.join("\n");
    }
}

document.getElementById("gen").onclick = init;