Sorting Selected Text Frame or Document Cause Changing Some Word Letters Colors!
Hi Experts,
Im trying to sort the arabic text and some letters are colored in green and others are black , it works but after sorting some words green letters color changed to white! , it looks like it dissapeared!, i dont know why! , here is the script and screen shots :
//UNDO Enabled
app.doScript(CatchMyError, ScriptLanguage.JAVASCRIPT, undefined, UndoModes.ENTIRE_SCRIPT, "Sort Story");
//Error Catcher for Function
function CatchMyError(){
try {
CheckSelection();
} catch (myError) {
alert (myError,"ERROR!");
exit();
}
}
function CheckSelection(){
// Check that a story is selected
var myCurrentSelection = app.selection[0];
if(app.selection.length < 1 && myCurrentSelection != Story) {
alert ("Plese Select Text Frame First!","ERROR!");exit();
}else{
SortSelection();
}
}
function SortSelection(){
//Create an array of paragraphs by splitting the Story
myArray = app.selection[0].parentStory.contents.split ('\r');
//Sort the array
myArray.sort();
//Join the array as one string separated by hard returns
myString = myArray.join ('\r');
//Replace the contents of the selected story with myString
app.documents[0].textFrames[0].parentStory.texts[0].contents = myString;
}here is screen shots for before and after :
Before Shot
After Shot

here is link for the file and video in weTransfer :
Project Folder and Video
did i make something wrong? please help to fix and thanks in advance
