Highlighted

function for undo/redo

Community Beginner ,
Sep 10, 2020

Copy link to clipboard

Copied

Hi there,

I have a JSX file that has multiple scripts that I have built. I am hoping there is a way to build a undo/redo function that I can use inside each script. 

Example. I have a panel that when I click a button for branding the text to my companies font. if I want to undo this I have to undo multiple times, to remove hyphenation, color, size, text_align, etc. then it goes back to the original before the script runs. I saw some people post a function that wraps your script, but the problem I have would be that the HTML file is looking for the function that would be inside the undo function.

Since I have so many different scripts I was hoping I could do something like the following.

function textChange() {
//style font
undoRedo();
}

function undoRedo() {
//way to ask which function script to redo
}

 

Is this possible?

TOPICS
Scripting

Views

63

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

function for undo/redo

Community Beginner ,
Sep 10, 2020

Copy link to clipboard

Copied

Hi there,

I have a JSX file that has multiple scripts that I have built. I am hoping there is a way to build a undo/redo function that I can use inside each script. 

Example. I have a panel that when I click a button for branding the text to my companies font. if I want to undo this I have to undo multiple times, to remove hyphenation, color, size, text_align, etc. then it goes back to the original before the script runs. I saw some people post a function that wraps your script, but the problem I have would be that the HTML file is looking for the function that would be inside the undo function.

Since I have so many different scripts I was hoping I could do something like the following.

function textChange() {
//style font
undoRedo();
}

function undoRedo() {
//way to ask which function script to redo
}

 

Is this possible?

TOPICS
Scripting

Views

64

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Sep 10, 2020 0
Adobe Community Professional ,
Sep 10, 2020

Copy link to clipboard

Copied

Hi There,

It does not work exactly the way you want, but what you can do is wrap the whole operations of a script or function into a single step for undo. So if you call multiple functions/scripts using this way each of these functions/scripts would have a single entry on the undo/redo stack. Play around with the following operations you will get an idea of what can be done

app.doScript()

app.undo()

document.undo()

-Manan

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Sep 10, 2020 1
Community Beginner ,
Sep 10, 2020

Copy link to clipboard

Copied

okay, I will give these a try. do you know if there is a way to merge the history of layers that are created in the script into one history? This way undo only has to be hit once.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Sep 10, 2020 0
Adobe Community Professional ,
Sep 10, 2020

Copy link to clipboard

Copied

The only way to squash history of multiple versions into a single is the doScript method. However, that includes all the operations done in the function/script passed to it and is not restricted to just the layer operations. So the idea for you would be to isolate the operations that you want to be logically connected into a function and call that function using doScript method, In such a case all these operations would then be eligible to be reverted back in a single undo.

-Manan

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Sep 10, 2020 0