-
Notifications
You must be signed in to change notification settings - Fork 109
feat: Enable parsing of rich (smart) tags in google docs #215
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -444,6 +444,16 @@ export class DocsService { | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| element.paragraph.elements?.forEach((pElement) => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (pElement.textRun && pElement.textRun.content) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| text += pElement.textRun.content; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } else if (pElement.person?.personProperties) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const { name, email } = pElement.person.personProperties; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| text += `[${name || email}](mailto:${email})`; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } else if (pElement.richLink?.richLinkProperties) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const { title, uri } = pElement.richLink.richLinkProperties; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| text += `[${title}](${uri})`; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } else if (pElement.dateElement?.dateElementProperties) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const { displayText, timestamp } = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| pElement.dateElement.dateElementProperties; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| text += displayText || timestamp || ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
445
to
457
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For improved consistency and robustness, consider using optional chaining ( Using Using
Suggested change
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Double check your understanding from here, most of these fields "always exist" according to the client library |
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } else if (element.table) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
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.
The tests for fallback scenarios are quite similar and contain a lot of boilerplate code. To improve maintainability and reduce duplication, you could use Jest's
it.eachto parameterize these tests. This would make the test suite more concise and easier to extend with new fallback cases in the future.