-
Notifications
You must be signed in to change notification settings - Fork 3
(feat) Add column info to section properties #9
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
Conversation
luiisgallego
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In general it looks good, but the code could be improved a bit more. Also, I think there are cases not covered yet, but I am not entirely sure. Added Ines as reviewer, since she did the TD, so she can help with the next revisions.
src/properties/section-properties.ts
Outdated
| numberOfColumns: null | number; | ||
| equalWidth: null | boolean; | ||
| separator: null | boolean; | ||
| columns?: {columnWidth: Length | null, columnSpace?: Length | null}[] | null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe "definition" or something like that in order to avoid repeating "columns" twice.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apart from that, in which case does the "columns" property not exist?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Columns are missing when all columns have equal size (equalWidth is true). What I don't understand is why some properties are optional (?), and some other aren't, but at the same time those can be null. Are those optional? They aren't...?
src/properties/section-properties.ts
Outdated
| if (!node) { | ||
| return {}; | ||
| } | ||
| }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems to be necessary because the createXmlRoundRobinTest function used in the test suite expects null to be a possibility. Not a great reason, but it is the reason.
As for why it's that way, it seems like we were trying to cover the possibility that certain elements might not be there as we create a document. If this is something we need to dive into more, let's open a new issue for it.
src/properties/section-properties.ts
Outdated
| "equalWidth": docxml:st-on-off(./${QNS.w}cols/@${QNS.w}equalwidth), | ||
| "columns": array{ | ||
| ./${QNS.w}cols/${QNS.w}col/map{ | ||
| "columnWidth": if (@${QNS.w}w) then docxml:length(@${QNS.w}w, 'twip') else (), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the condition necessary?
src/properties/section-properties.ts
Outdated
| export function sectionPropertiesToNode(data: SectionProperties = {}): Node { | ||
| return create( | ||
|
|
||
| // console.log(data.columns?.columns?.forEach((col) => { console.log(col.columnWidth)})) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove!
| } | ||
| ); | ||
| }); | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove extra spaces.
| equalWidth: false, | ||
| separator: true, | ||
| columns: [ | ||
| {columnWidth: twip(1440), columnSpace: twip(720)}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prettier does not work in this repo. Fix it in this PR, or create another one and then fix this indentation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| attribute ${QNS.w}equalwidth { $columns('equalWidth') }, | ||
| attribute ${QNS.w}num { $columns('numberOfColumns') }, | ||
| if (docxml:st-on-off(string($columns('equalWidth')))) then () |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When there is no "columns" information, does the "equalWidth" attribute always exist?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add more tests forcing incorrect scenarios? Maybe some missing properties? Extra/unknown properties?
src/properties/section-properties.ts
Outdated
| numberOfColumns: null | number; | ||
| equalWidth: null | boolean; | ||
| separator: null | boolean; | ||
| columns?: {columnWidth: Length | null, columnSpace?: Length | null}[] | null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Columns are missing when all columns have equal size (equalWidth is true). What I don't understand is why some properties are optional (?), and some other aren't, but at the same time those can be null. Are those optional? They aren't...?
src/properties/section-properties.ts
Outdated
| equalWidth: null | boolean; | ||
| separator: null | boolean; | ||
| columns?: {columnWidth: Length | null, columnSpace?: Length | null}[] | null; | ||
| }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
; is unnecessary
| @@ -1,8 +1,7 @@ | |||
| import { describe, run } from 'https://deno.land/x/[email protected]/mod.ts'; | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please, rebase the PR.
850073d to
44b4825
Compare
This PR adds basic support for the section properties necessary to create a document with columns. The
SectionPropertiestype should now handle Word documents with<w:cols>elements, and any subsequent<w:col>elements for individually specified columns.