This content has been marked as final. Show 4 replies
It would probably be easier to apply the styling to the insertion point<br />before the paste. But why are you pasting at all? There's rarely a need.<br /><br />-- <br />Shane Stanley <email@example.com>
Hi Shayne, thanks for responding.
The larger goal for the script is to execute a kind of "paste without formatting" that preserves local formatting/overrides (itlas, bolds, character styles). The native feature does not support this.
A designer will have live text, say, on the pasteboard, will copy the live text, then select a destination. The destination contains dummy text, formatted with the desired attributes. The live text needs to pick up the attributes and replace the dummy text, preserving overrides.
The script creates a temporary style sheet capturing the destination attributes, pastes (which replaces the dummy text, putting the live text into position), applies the style sheet (giving the attributes but retaining overrides), then delete the temporary style. Of course as you're pointing out, the style sheet could be applied before pasting.
If I'm thinking about this correctly, the problem is that the source text could have multiple paragraphs. Setting the insertion point with the desired attributes would take care of the first paragraph, but not the subsequent ones.
Meanwhile, if you can find an easy way to do this without copy/paste. . . that would be fantastic!
You can get the information you need by getting the index of the insertion<br />point and length of the story before you paste. After you paste, you can<br />then refer to text from character insertionIndex to character insertionIndex<br />+ lengthAfter - lengthBefore.<br /><br />-- <br />Shane Stanley <firstname.lastname@example.org>
Shane, thanks for this I'll try it out!