Copy link to clipboard
Copied
Hi All,
Is there any options Removes Shortcut keys assign to Stylesheets.
I have attached before and after screenshots below:
Thanks,
Prabu
Copy link to clipboard
Copied
There is no property on the DOM to access this information directly. Go through the following threads for some ideas on how you can do it
is it possible to assign a keyboard shortcut in a script to style
Re: Scripting Styles keyboard shortcuts
-Manan
Copy link to clipboard
Copied
Hi together,
you may have noticed that if you duplicate a paragraph style in the UI the keyboard shortcut will not be duplicated.
So I tried the following snippet:
/*
Text selected where the applied paragraph style has a keyboard shortcut ( KBSC ).
I want to get rid of the KBSC so I try to duplicate the style in the hope that the duplicate has no KBSC applied.
Unfortunately that's not the case!
The duplicate style has the same KBSC than the source.
Something you cannot do with the UI.
*/
var sourceStyle = app.selection[0].appliedParagraphStyle ;
var sourceStyleName = sourceStyle.name ;
var tempStyle = sourceStyle.duplicate();
// Will not work as expected.
// The KBSC is still there:
sourceStyle.remove( tempStyle );
tempStyle.name = sourceStyleName;
Two paragraph styles with the same KBSC after running lines 11 to 13 of the code snippet above:
So we need a different solution.
With an edited IDMS file perhaps.
Regards,
Uwe
Copy link to clipboard
Copied
Ananth@desgin, https://forums.adobe.com/people/Manan%20Joshi Lauender
I found that if you add new paragraph style(s) using "basedOn" the keyboard shortcut are not included.
In the script below the new temporary styles retain all the correct style properties/settings until the script removes and replaces the original styles. I guessing that's do to the fact that the "basedOn" styles have been removed and the new styles no longer have their reference.
How can we work out that issue?
var doc = app.documents[0];
function myGetParaStyles(){
var myParaStyles = new Array;
for (var i = 2; i < doc.paragraphStyles.length; i++){
myParaStyles.push(doc.paragraphStyles.name);
}
return myParaStyles;
}
var myStylesToReplace = myGetParaStyles();
var allParaStyles = app.activeDocument.allParagraphStyles;
function myGetNewParaStyles(){
var myNewParaStyles = new Array;
for (var i = 2; i < allParaStyles.length; i++) {
var curStyle = doc.paragraphStyles.itemByName(allParaStyles.name);
var parastylesName = allParaStyles.name;
var copyStyle= doc.paragraphStyles.add(allParaStyles);
copyStyle.basedOn = curStyle;
copyStyle.name = parastylesName + "-copy";
curStyle = copyStyle;
myNewParaStyles.push(copyStyle.name);
}
return myNewParaStyles;
}
var myNewStyles = myGetNewParaStyles();
try {
for (var i = 0; i < myStylesToReplace.length; i++){
for (var i = 0; i < myNewStyles.length; i++){
doc.paragraphStyles.item(myStylesToReplace).remove(myNewStyles);
}
}
} catch(e) {}
pstyles = app.documents[0].allParagraphStyles;
for (i = pstyles.length-1; i > 1; i--) {
pstyles.name = pstyles.name.replace(/\-copy/g,'');
}
Regards,
Mike
Copy link to clipboard
Copied
Surely too late but Just For Comment:
(^/) The Jedi