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

Rework of collection functions + graphics() + textStyleRanges() #289

Merged
merged 8 commits into from
Oct 16, 2018

Conversation

trych
Copy link
Contributor

@trych trych commented Oct 15, 2018

This standardizes and cleans up the collection functions (e.g., words(), characters, items() etc.) and adds two new ones: graphics() and textStyleRanges().

Changes in detail:

  • collection functions now always return collections (or arrays), also when a callback function is used
  • if a callback functions is used that returns falls at some point and interrupts the loop, a collection of elements up to that point is returned
  • same behaviour goes for forEach()
  • legal containers were made more consistent between functions and additional possible containers were added for many functions (e.g., words on a layer, words in a group, items in a paragraph etc.)
  • docs were improved to be easier to understand (I hope)
  • internal cleanup, including the removal of private function forEachTextCollection() which was no longer needed
  • graphics() was added as discussed in Easier transforming of images #120 to allow changing the graphics within containers, like the graphic in a graphic frame.
  • textStyleRanges() was added as discussed in Introduce b.addToText(), discontinue b.addToStory() #72 to allow looping over, well, text style ranges. :)
  • stories() now allows for text frames or text objects as containers to get their parent story, as discussed in Introduce b.addToText(), discontinue b.addToStory() #72.

@basiljs I will leave this up for review for a day or so, if there are no vetoes, I will go ahead and merge.

trych added 6 commits October 15, 2018 13:45
- collection functions now always return a collection, also when callback functions are used
- if a callback function returns false and aborts the loop, the collection up to this point is returned as an array
- additional containers are allowed now for text collections and for items()
- got rid of private function forEachTextCollection() as it was not needed anymore
- rewriting of the collection functions docs, to make the functions easier to understand
@ff6347
Copy link
Member

ff6347 commented Oct 16, 2018

Cool thing. What about some test coverage for the new functions?

@trych
Copy link
Contributor Author

trych commented Oct 16, 2018

Added some testing.
Feel free to add to this testing (or any testing for this matter) whenever you feel, there are specific features that should be tested.

Will merge now.

@trych trych merged commit 3480c8e into develop Oct 16, 2018
@trych trych deleted the collections branch October 16, 2018 22:07
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