-
Notifications
You must be signed in to change notification settings - Fork 29
fix: markdown rendering for custom types #483
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
base: main
Are you sure you want to change the base?
Changes from 9 commits
9b9c553
d8e88bc
90b6db8
33e983a
74bb4c2
c433b01
8f4003d
fdfb366
56045b6
9995833
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 |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| const IMAGE_EXTS = new Set(['png', 'jpg', 'jpeg', 'gif', 'webp', 'svg', 'mp4', 'webm', 'mov']); | ||
| const TABLE_EXTS = new Set(['json', 'xlsx', 'xls', 'csv']); | ||
|
|
||
| export function fileIconName(filename) { | ||
|
Member
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. the old code had a comment saying this mirrors entryTypeFromExtension in browse/utils.js. we removed the comment but the duplication is still there. why not move fileIconName to nx2/utils/ and delete browse/utils.js's version, or at least import from there? two parallel implementations will diverge.
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. Browse doesnt exist anymore - the comment is a remnant from when we had custom browse block similar to chat. |
||
| const ext = (filename ?? '').includes('.') ? filename.split('.').pop().toLowerCase() : ''; | ||
| if (IMAGE_EXTS.has(ext)) return 's2-icon-image-20-n'; | ||
| if (TABLE_EXTS.has(ext)) return 's2-icon-table-20-n'; | ||
| if (ext) return 's2-icon-filetext-20-n'; | ||
| return 's2-icon-3d-20-n'; | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| export function parseDirectives(text) { | ||
| const segments = []; | ||
| const buf = []; | ||
| let type = null; | ||
| let openLine = null; | ||
|
|
||
| for (const line of text.split('\n')) { | ||
| if (!type && line.startsWith(':::')) { | ||
| const extracted = line.slice(3).split(' ')[0]; | ||
| if (!extracted) { | ||
| buf.push(line); | ||
| } else { | ||
| const content = buf.splice(0).join('\n'); | ||
| if (content) segments.push({ kind: 'text', content }); | ||
| type = extracted; | ||
| openLine = line; | ||
| } | ||
| } else if (type && line.trimEnd() === ':::') { | ||
| segments.push({ kind: 'directive', type, content: buf.splice(0).join('\n') }); | ||
| type = null; | ||
| openLine = null; | ||
| } else { | ||
| buf.push(line); | ||
| } | ||
| } | ||
|
|
||
| if (openLine) { | ||
| segments.push({ kind: 'directive', type, content: buf.join('\n') }); | ||
| } else { | ||
| const tail = buf.join('\n'); | ||
| if (tail) segments.push({ kind: 'text', content: tail }); | ||
| } | ||
| return segments; | ||
| } |
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.
can we set the URL via a JS custom property (--checkmark-icon: url(${...})) using codeBase, the same way inline SVG refs are handled instead of hardcoding the CDN url?
Uh oh!
There was an error while loading. Please reload this page.
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.
We could, but mask-image on a pseudo-element is purely decorative styling with no functional JS dependency. Adding a custom property would couple js and css just to avoid a stable CDN URL and the trade-off didnt feel worth it here.