-
Notifications
You must be signed in to change notification settings - Fork 142
Add dataTable plugin #2446
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
Add dataTable plugin #2446
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #2446 +/- ##
==========================================
+ Coverage 50.80% 51.05% +0.25%
==========================================
Files 125 126 +1
Lines 5437 5467 +30
Branches 1170 1174 +4
==========================================
+ Hits 2762 2791 +29
- Misses 2380 2381 +1
Partials 295 295 ☔ View full report in Codecov by Sentry. |
yucheng11122017
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.
Hi @Tim-Siu thanks for the work on this!
Before you continue, I think one is that this will always sort by text.. which is not necessarily what is needed. For example, the example that you gave perhaps you want to sort by numbers instead? But currently, if you add 28 vs 201, 201 will come before 28.
Also, could you make sure that this will work for external imports as well? I think it doesn't work for now.
|
Hi @Tim-Siu thank you for the amazing work; |
|
Nice effort @Tim-Siu
|
Solve the problem that the original `markdown-it` is modified
Merge master
|
Great addition to tables @Tim-Siu! I just have two small nits from a UI perspective.
Great work so far! |
|
looks p good to me! - but wondering 2 things
|
Sure! I will explore different UI. I think there are some existing implementations on the internet for bootstrap tables and I will try to refer to them. |
Add support for searching Improve TS code style
|
Hi @damithc , I updated the plugin and it is now able to support both sorting and filtering. This is all, however, powered by DataTables, which is a Javascript table library that is loaded from CDN directly. What do you think of the functioinality now? There are additional features like paging and scrolling from DataTable. Are these features needed? Thanks for your advice. |
@Tim-Siu Good find. |
|
Other concerns to check on:
|
Hi @damithc , Thank you for your input! Regarding your concern:
I do realise that the plugin is not working inside a panel or modal. It seems to suffer the same problem as the mermaid plugin #2052 . I am still investigating this issue. |
@Tim-Siu I see. That's a bummer, but if we figure out a way to fix it, we might be able to add both this and Mermaid to MarkBind, which would be REALLY great. Feel free to join forces with other team members (including mentors) to explore this, as this is likely hard to solve. |
|
Hi @Tim-Siu, can I check how to use this feature? I have added But it doesn't seem to work. Please add some documentation so that we can test it easily. |
Hi @yucheng11122017 , That is the correct usage. It does work on my side. Can you paste a screenshot of the output on your side? Screen.Recording.2024-03-14.at.21.43.26.mov |
--------- Co-authored-by: Chan Yu Cheng <[email protected]>
yucheng11122017
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.
Some nits and clean up!
docs/userGuide/plugins/dataTable.md
Outdated
|
|
||
| To create a table with DataTable features, use one of the following syntaxes: | ||
|
|
||
| 1. Sortable 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.
As I mean lines 19 to 52 is almost the same as 54 to 100 so its repetitive. We can delete 19 to 52 I think!
|
|
||
| let tableClass: string = ''; | ||
| if (isSortable && isSearchable) { | ||
| tableClass += ' sortable-searchable-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.
| tableClass += ' sortable-searchable-table'; | |
| tableClass = ' sortable-searchable-table'; |
| if (isSortable && isSearchable) { | ||
| tableClass += ' sortable-searchable-table'; | ||
| } else if (isSortable) { | ||
| tableClass += ' sortable-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.
| tableClass += ' sortable-table'; | |
| tableClass = ' sortable-table'; |
| } else if (isSortable) { | ||
| tableClass += ' sortable-table'; | ||
| } else if (isSearchable) { | ||
| tableClass += ' searchable-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.
| tableClass += ' searchable-table'; | |
| tableClass = ' searchable-table'; |
| { | ||
| "glob": ["**/index.md", "**/*.md"] | ||
| }, | ||
| { |
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 delete these two pages - they aren't needed for testing!
* Change seamless panels * Improve look of seamless panels * Add tests * Update userguide example --------- Co-authored-by: Chan Yu Cheng <[email protected]> Co-authored-by: Hannah <[email protected]>
itsyme
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.
Just two small nits to make the documentation and code slightly more readable! Almost there!
| $('d-table').each((index: number, node: cheerio.Element) => { | ||
| const $node = $(node); | ||
| const html = $node.html(); | ||
| if (html != 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.
My opinion is it would be cleaner to use a guard clause here. i.e. check for html == null instead of html != null and continue/return. This allows the main logic of the code to not be wrapped in the if block, making it cleaner/more readable.
Here's a useful article on guard clauses: https://deviq.com/design-patterns/guard-clause
yucheng11122017
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.
Some comments
| { | ||
| "glob": ["**/index.md", "**/*.md"] | ||
| }, | ||
| { |
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.
|
|
||
| test('postRender should add appropriate classes and attributes to m-table elements', () => { | ||
| const content = ` | ||
| <m-table sortable> |
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.
Isnt this supposed to be d-table now?
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 does the test case still pass when the tag is m-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.
Why does the test case still pass when the tag is m-table?
Thank you for pointing it out. It turns out it is necessary to verify the length of the output. Currently, if I use , the length of the output after the selector is 0, leading to a vacuously true situation.
Fix the problem that there is a additional space in table attribute
yucheng11122017
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.
Some comments
| ]; | ||
|
|
||
| const renderedContent = dataTable.postRender({}, {}, content); | ||
| console.log(renderedContent); |
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.
Do we need this console.log?
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.
Sorry I forgot to clean this up...
|
|
||
| test('postRender should add appropriate classes and attributes to m-table elements', () => { | ||
| const content = ` | ||
| <d-table sortable> |
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 is the formatting here like 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.
It seems like that if there are tabs indentation, it will be rendered as code...I haven't figured out why.
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 is the formatting here like this?
I think this is the bahaviours for all the Vue components. (The behaviours that if we put indentations, the Vue comoponents won't be rendered correctly.
itsyme
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.
LGTM! Ready to be merged after resolving the latest comments from @yucheng11122017!
yucheng11122017
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.
LGTM! Thanks for the work
|
LGTM! Thanks for the work @Tim-Siu |

What is the purpose of this pull request?
Overview of changes:
Contribute to #896
Added a
dataTableplugin. When we put a table into<m-table sortable>tag, it will become a Sortable Table. When we put a table into<m-table searable>tag, it will become a Searchable Table. Both functions can be used together.DataTable is used.
Sample usage:
Result:
Screen.Recording.2024-03-14.at.21.43.26.mov
Anything you'd like to highlight/discuss:
This has the potential of breaking the rendering pipeline. I am still conducting tests.
Testing instructions:
See overview.
Proposed commit message: (wrap lines at 72 characters)
Add
dataTablepluginChecklist: ☑️
Reviewer checklist:
Indicate the SEMVER impact of the PR:
At the end of the review, please label the PR with the appropriate label:
r.Major,r.Minor,r.Patch.Breaking change release note preparation (if applicable):
Previously tables do not support searching and sorting.
Authors can now enable these features by adding dataTable as a site plugin and add the respective syntax around the table.