Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adding pasteInto() #368

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open

adding pasteInto() #368

wants to merge 3 commits into from

Conversation

ffd8
Copy link
Member

@ffd8 ffd8 commented Dec 30, 2020

  • student duo tried to export text as a png, then import to create a clipping mask. this is akin to the GUI right-click 'pasteInto', which opens gates for wild clipping masks and within clipping masks inception!

- student duo tried to export text as a png, then import to create a clipping mask. this is akin to the GUI right-click 'pasteInto', which opens gates for wild clipping masks and within clipping masks inception!
@ffd8 ffd8 requested review from trych and ff6347 December 30, 2020 22:56
@ffd8
Copy link
Member Author

ffd8 commented Dec 30, 2020

this is a minor feature – but it would help to have a quick look over incase anything is wrong..

fixing small typo
@ffd8
Copy link
Member Author

ffd8 commented Dec 31, 2020

small update – tried integrating isText() function on the newly masked pageItem.. but realized it doesn't catch it.. maybe because it's a text within the pageitem... needing to be reached with destination.pageItems[0].hasOwnProperty('texts'). Maybe this type of hasproptery check should find its way up the stream to the isText() function itself.. or just leave alone?

@trych
Copy link
Contributor

trych commented Jan 2, 2021

Hey @ffd8,
sorry for the lack of replies, I am not very active here currently as I am really occupied with other stuff.

Is there a way to "paste into" without using the actual copy() and paste() methods? I seem to recall you could avoid those entirely and that they are not supported on InDesign Server. If not, let's just go ahead and use them.

Two observations:

  • Why does the text get returned when I paste the text frame into an object? I get that users most likely want to change the text eventually, but it just feels really inconsistent. What if a user actually wants to target the text frame? I think it would be preferrable if it's always the pasted object that is returned and then in this case, users have to access the .texts[0] property themselves.
  • as it is currently implemented, this method resets the user's selection. The method should take care to reset the selection to whatever it was before.

Copy link
Contributor

@trych trych left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See my comment above. I am too dumb to use GitHub's review feature properly lol

- fixing as per review suggestion
@ffd8
Copy link
Member Author

ffd8 commented Jan 4, 2021

@trych – noo problemo, this project jumps between front/back burners, so i totally understand.
nevertheless, thanks for having a quick look!

I also don't really get the review feature – so just plain old comments are also preferred.

To my knowledge, pasteInto totally depends on the clipboard, Jongware on pasteInto notes:

Pastes data from the clipboard into the selected object ...

I originally found the solution for what to do in this StackOverflow.

Re: returned object when text is involved.. yeah, wanted to return whichever type of object was being fed into it (for ease with students.. feed text into mask, when set as var = your text now masked). Figuring out what to return was odd.. the same paths seem to be the same item within the mask after pasteInto():

  • myMask.textFrames[0] » expected text
  • myMask.pageItems[0].texts[0] » expected text
  • myMask.pageItems[0].textFrames[0] » null

I went with the later, because when feeding any other pageItem into the mask, you want the mask.pageItems[0] back.. so I figured that the .pageItems[0].texts[0] was preferable (to still work with pageItem) – but happy to use either.. just important that the actual text(Frame) gets returned. Is there actually a difference or to InDesign, it's the same object?? Happy to change it to option using textFrames[0].

Re: selection, yup, you're totally right, the selection should be temp stored and returned when done! aaand changed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants