-
-
Notifications
You must be signed in to change notification settings - Fork 13
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
row.styles in tables #63
Comments
Hi! I was also stumbling upon this in the past. To grub out the roots: I guess it is because of
assertElement(
collection: HTMLCollectionOf<Element>,
index: number,
tag: string,
parent: XmlDocument | XmlElement,
modifier: Modification,
): XmlDocument | XmlElement | boolean {
if (!collection[index]) {
if (collection[collection.length - 1] === undefined) {
this.createElement(parent, tag);
} else {
const previousSibling = collection[collection.length - 1];
// this.templates[tag] will be taken by default, and this is your first row:
const newChild =
this.templates[tag] && !modifier.fromPrevious
? this.templates[tag].cloneNode(true)
: previousSibling.cloneNode(true);
XmlHelper.insertAfter(newChild, previousSibling);
}
} I'm not sure on this, but using
row = (index: number, children: ModificationTags): ModificationTags => {
return {
'a:tr': {
// like this, but it will be best to let the user decide:
fromPrevious: true,
index: index,
children: children,
},
};
}; I did not test this, but it should change the behaviour as expected! Thanks again for pointing out! |
@singerla So I am using a more high-level API in the form of And what I see with that is if I am adding 3 rows and set say background colour on row 2 then it also applies to row 3 (as it seems to clone that node not the vanilla node I have in the actual file). Is it possible to say that there should not be any colour set using |
I have canged it to row = (index: number, children: ModificationTags): ModificationTags => {
return {
'a:tr': {
forceCreate: true,
index: index,
children: children,
},
};
}; as this also has crashed one of my projects. |
When adding new rows to a table using the ModifyTable class, it currently applies the styles of row 0 to the new rows (well actually an empty style object and this seems to be powerpoints default behaviour for that). For instance, if row 0 is a header with larger and bold text, and rows 1-3 have normal smaller text, calling modify with 10 rows results in rows 1-3 keeping their original text style, while rows 4-9 have the header text style.
Although it's possible to override this using the style object for each row, it requires the application to be aware of the table styling, instead of allowing the user to freely style it in the template file and have the styles respected.
It doesn't actually matter in my use of this library whatsoever but I did stumble upon it, and it seemed perhaps suboptimal.
To address this, we could introduce a "has header" toggle or a "repeatLastRowStyles" option that repeats last row style rather than empty row style. This would allow the user to choose how new rows should inherit styles from existing rows, providing a more flexible solution.
Something like this ? What do you think :)
The text was updated successfully, but these errors were encountered: