Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion packages/sciux/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
},
"dependencies": {
"@sciux/layout": "workspace:*",
"@sciux/math": "workspace:*",
"@sciux/model": "workspace:*",
"@sciux/widget": "workspace:*",
"sciux-laplace": "catalog:"
Expand Down
6 changes: 4 additions & 2 deletions packages/widget/src/canvas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@ export default defineComponent<'canvas', typeof CanvasType.infer>((attrs) => {
setup(children) {
const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg')
svg.setAttribute('viewBox', `0 0 ${attrs.width.value} ${attrs.height.value}`)
svg.setAttribute('width', '100%')
svg.style.aspectRatio = (attrs.width.value / attrs.height.value).toString()

svg.style.height = attrs.height.value.toString()
svg.style.width = attrs.width.value.toString()

const root = document.createElementNS('http://www.w3.org/2000/svg', 'g')
root.setAttribute('transform', `translate(${attrs.origin.value.join(',')})`)
root.append(...children())
Expand Down
9 changes: 6 additions & 3 deletions packages/widget/src/code.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,19 @@ export default defineComponent<'code', typeof T.infer>((attrs) => {
attrs: T,
setup(children) {
const container = document.createElement('div')
container.style.width = '100%'
container.style.height = '100%'
const kids = children()
// Filter out text nodes
const content = kids[0].textContent ?? ''
const html = highlighter.codeToHtml(content, {
lang: attrs.language.value,
theme: 'github-dark',
})
container.innerHTML = html

container.innerHTML = html;

(container.childNodes[0] as HTMLElement).style.paddingLeft = '1rem';
(container.childNodes[0] as HTMLElement).style.paddingRight = '1rem'

return container
},
}
Expand Down
Loading
Loading