Skip to content
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

feat(unify): removing prism and adding infrastructure for shiki #18514

Merged
merged 49 commits into from
Oct 19, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
288f854
feat: use shikijs for highlighting code
elevatebart Oct 15, 2021
04f80da
add line numbers
elevatebart Oct 15, 2021
5ff4766
fix Jess's remarks
elevatebart Oct 15, 2021
7652eb2
remove last instances of prism
elevatebart Oct 15, 2021
07cf11e
fix: remove unused prism packages
elevatebart Oct 15, 2021
199ced0
fix broken build
elevatebart Oct 15, 2021
9b21d6e
remove prism
elevatebart Oct 15, 2021
d2cfe60
remnove prism one last time
elevatebart Oct 15, 2021
69f416f
remove the last piece of prism in tests
elevatebart Oct 16, 2021
81aa7eb
remove prism and refactor
elevatebart Oct 16, 2021
233b9da
restore proper fe-shared test
elevatebart Oct 16, 2021
0eeae6e
use windi to color shiki
elevatebart Oct 16, 2021
3693b3b
rename theme and create test
elevatebart Oct 16, 2021
60929e5
cosmetic fixes
elevatebart Oct 16, 2021
29a75f7
Merge branch 'unified-desktop-gui' into spike/use-shiki
elevatebart Oct 18, 2021
407127d
avoid the jank
elevatebart Oct 18, 2021
e21c7aa
fix image imports in typescript
elevatebart Oct 18, 2021
8fe21f2
restore mistake
elevatebart Oct 18, 2021
ef06a82
make the shiki theme generator
elevatebart Oct 18, 2021
3fb08e9
gitignore the shiki-heme generated
elevatebart Oct 18, 2021
f7ccbc6
add the shiki theme generation to yarn build
elevatebart Oct 18, 2021
ace67eb
make shiki theme look good
elevatebart Oct 18, 2021
7c322fd
last colors to update
elevatebart Oct 18, 2021
bb5a38e
styling fixes
JessicaSachs Oct 19, 2021
f86e81f
Merge branch 'spike/use-shiki' of https://github.com/cypress-io/cypre…
JessicaSachs Oct 19, 2021
6dcfb9b
styling fixes
JessicaSachs Oct 19, 2021
952ef4c
styling fixes
JessicaSachs Oct 19, 2021
3d75ee6
styling fixes
JessicaSachs Oct 19, 2021
705b893
theme
JessicaSachs Oct 19, 2021
afe9f2d
fix relative positioning
JessicaSachs Oct 19, 2021
5d5057e
Update .gitignore
JessicaSachs Oct 19, 2021
55958a7
Update packages/frontend-shared/src/components/ShikiHighlight.vue
JessicaSachs Oct 19, 2021
c607b47
remove conflicting copy button
JessicaSachs Oct 19, 2021
d50cc68
Merge branch 'spike/use-shiki' of https://github.com/cypress-io/cypre…
JessicaSachs Oct 19, 2021
087debc
dont top level await
lmiller1990 Oct 19, 2021
452e7f6
add a readme for theme generation
elevatebart Oct 19, 2021
029fb48
ignore generated theme
elevatebart Oct 19, 2021
d91d2c4
fix integration test in launchpad
elevatebart Oct 19, 2021
730be2b
fix other integration test
elevatebart Oct 19, 2021
294f6ff
Merge branch 'unified-desktop-gui' into spike/use-shiki
Oct 19, 2021
871ca03
bring back the cypress theme
elevatebart Oct 19, 2021
b42c22b
fixing public path issue
JessicaSachs Oct 19, 2021
bbbb111
Merge branch 'spike/use-shiki' of https://github.com/cypress-io/cypre…
JessicaSachs Oct 19, 2021
6e54730
make e2e work
elevatebart Oct 19, 2021
55789ae
fix yarn dev (remove the double slash)
elevatebart Oct 19, 2021
8da29c1
review theme with ryan
elevatebart Oct 19, 2021
253693c
make copy on click optional
elevatebart Oct 19, 2021
82188c1
adjust viewports
elevatebart Oct 19, 2021
25a521e
move generation of theme before vite build
elevatebart Oct 19, 2021
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: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"json"
],
"editor.codeActionsOnSave": {
"source.fixAll": true,
"source.fixAll.eslint": true
},
"typescript.tsdk": "node_modules/typescript/lib"
Expand Down
4 changes: 3 additions & 1 deletion packages/frontend-shared/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@
"cypress:run": "cross-env TZ=America/New_York node ../../scripts/cypress run-ct --project ${PWD}",
"dev": "vite --open"
},
"dependencies": {},
"dependencies": {
"shiki": "^0.9.12"
},
"devDependencies": {
"@antfu/utils": "^0.3.0",
"@cypress/vite-dev-server": "0.0.0-development",
Expand Down
35 changes: 35 additions & 0 deletions packages/frontend-shared/src/components/ShikiHighlight.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<script lang="ts" setup>
import { computed, onBeforeMount, ref } from 'vue'
import { highlighter, initHighlighter } from '../highlighter'

const highlighterInitialized = ref(false)

onBeforeMount(async () => {
await initHighlighter()
highlighterInitialized.value = true
})

const props = defineProps<{
code: string;
lang: 'javascript' | 'typescript' | 'json' | 'js' | 'ts';
}>()

const resolvedLang = computed(() => 'js' === props.lang ? 'javascript' : 'ts' === props.lang ? 'typescript' : props.lang)

const highlightedCode = computed(() => {
return highlighter?.codeToHtml(props.code, props.lang)
})
</script>

<template>
<div
v-if="highlighterInitialized"
v-html="highlightedCode"
/>
</template>

<style>
.shiki{
padding: 16px;
}
</style>
18 changes: 18 additions & 0 deletions packages/frontend-shared/src/highlighter.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { Highlighter, getHighlighter, setOnigasmWASM, setCDN } from 'shiki'
import onigasm from 'onigasm/lib/onigasm.wasm?url'

setOnigasmWASM(onigasm)
setCDN('/shiki/')

export let highlighter: Highlighter

export async function initHighlighter () {
if (highlighter) {
return
}

highlighter = await getHighlighter({
themes: ['cypress'],
langs: ['typescript', 'javascript', 'css', 'json'],
})
}
Loading