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

b.objectStyle(), b.characterStyle() and b.paragraphStyle() don't work #64

Closed
trych opened this issue Jul 20, 2016 · 8 comments
Closed

Comments

@trych
Copy link
Contributor

trych commented Jul 20, 2016

As the title states, neither of these methods work at the moment, as they make an incorrect call to findInCollectionByName() by only providing a name parameter instead of both a collection and name parameter. At the moment the methods conveniently return the first letter of the paragraphStyle name you provide. ;)

I suggest getting rid of the findCollectionByName() helper function altogether and replace it by collection.itemByName("name").isValid throughout basil.js.

@trych
Copy link
Contributor Author

trych commented Jul 20, 2016

And we have to think about how to handle paragraphStyleGroups.
I would suggest that when adding a new paragraphStyle with the method we should only allow them to be added to the top level.

For getting a paragraphStyle with the method, we could either

1.) Decide to only search on top level (assuming that in basil.js scripts hardly ever a paragraphStyleGroup will be used)
2.) or we can search through all paragraphStyleGroups and return the first style with the name that is found, similar to how b.nameOnPage() returns the first page item of the name that it finds. This would require a helper function, as the property doc.allParagraphStyles that we need provides an array, not a collection, so we could not use itemByName.

Opinions?

@ff6347
Copy link
Member

ff6347 commented Jul 20, 2016

@trych I'm until beginning of August to busy to review this. Basically we can't ignore those damn groups so we need to fix this. If the helper is not working we should fall back to IDAPI calls.

@ff6347
Copy link
Member

ff6347 commented Jul 20, 2016

So option 2 it is.

@trych
Copy link
Contributor Author

trych commented Jul 20, 2016

@fabiantheblind No worries! No need to respond to everything immediately, it is just that I finally found some time right now, so I want to hunt for bugs and bring the project forward, so atm I just post issues when I find some. Of course they can all be reviewed when you or somebody else finds the time. Github issues don't expire. ;)

And yes, I agree it should be option 2, so we get rid of one helper function and add another small helper function to handle the styleGroups where necessary.

Small side question:
Which notation do you prefer for me to replace

newCol = findInCollectionByName(currentDoc().swatches, a);

(that expect either a [swatch] or null in return)?

A)

newCol = currentDoc().swatches.itemByName(a) || null;

B)

newCol = currentDoc().swatches.itemByName(a).isValid ? currentDoc().swatches.itemByName(a) : null;

C)

if (currentDoc().swatches.itemByName(a).isValid) {
  newCol = currentDoc().swatches.itemByName(a);
} else {
  newCol = null;
}

I prefer notation type A), it's the one that Douglas Crockford suggests for falling back on default values after receiving a false value and it's nice and short. However, not everybody likes (or maybe knows) it, so I wanted to ask, if it is okay to use.

@trych
Copy link
Contributor Author

trych commented Jul 22, 2016

Ok, just to let you guys know, I'm working on this. However, in the current master (so before my fixes) I found some minor errors with b.color() and one critical one (will create an issue later) and I don't get b.addToStory() to work at all at the moment (also in master, just reported that in issue #44 ). So I will investigate these errors first, before I do a PR.

@ff6347
Copy link
Member

ff6347 commented Jul 22, 2016

see #66, #67, #68

@b-g b-g removed the review label Oct 25, 2016
@ff6347
Copy link
Member

ff6347 commented Nov 11, 2016

@trych whats the status of this issue?

@trych
Copy link
Contributor Author

trych commented Nov 11, 2016

Just closed them.

@trych trych closed this as completed Nov 11, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants