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: add chobitsu (Chrome Devtools) for preview #201

Open
wants to merge 19 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8,571 changes: 8,571 additions & 0 deletions package-lock.json
tachibana-shin marked this conversation as resolved.
Show resolved Hide resolved

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions package.json
Expand Up @@ -91,5 +91,8 @@
"vite-plugin-dts": "^3.6.4",
"vue": "^3.4.3",
"vue-tsc": "1.9.0-alpha.3"
},
"dependencies": {
"chobitsu": "^1.4.6"
}
}
124 changes: 124 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 5 additions & 2 deletions src/SplitPane.vue
Expand Up @@ -2,7 +2,10 @@
import { ref, reactive, computed, inject } from 'vue'
import { Store } from './store'

const props = defineProps<{ layout?: 'horizontal' | 'vertical' }>()
const props = defineProps<{
layout?: 'horizontal' | 'vertical'
defaultSplit?: number
}>()
const isVertical = computed(() => props.layout === 'vertical')

const container = ref()
Expand All @@ -13,7 +16,7 @@ const showOutput = ref(store.initialShowOutput)

const state = reactive({
dragging: false,
split: 50,
split: props.defaultSplit ?? 50,
})

const boundSplit = computed(() => {
Expand Down
4 changes: 2 additions & 2 deletions src/editor/types.ts
@@ -1,5 +1,5 @@
import CodeMirrorEditor from "./CodeMirrorEditor.vue";
import MonacoEditor from "./MonacoEditor.vue";
import CodeMirrorEditor from './CodeMirrorEditor.vue'
import MonacoEditor from './MonacoEditor.vue'
tachibana-shin marked this conversation as resolved.
Show resolved Hide resolved

export type EditorComponentType = typeof CodeMirrorEditor | typeof MonacoEditor

Expand Down
2 changes: 1 addition & 1 deletion src/monaco/Monaco.vue
Expand Up @@ -43,7 +43,7 @@ const lang = computed(() => (props.mode === 'css' ? 'css' : 'javascript'))

const replTheme = inject<Ref<'dark' | 'light'>>('theme')!
onMounted(async () => {
const theme = await import('./highlight').then(r => r.registerHighlighter())
const theme = await import('./highlight').then((r) => r.registerHighlighter())
tachibana-shin marked this conversation as resolved.
Show resolved Hide resolved
ready.value = true
await nextTick()

Expand Down
5 changes: 2 additions & 3 deletions src/monaco/highlight.ts
Expand Up @@ -7,17 +7,16 @@ import langVue from 'shikiji/langs/vue.mjs'
import themeDark from 'shikiji/themes/dark-plus.mjs'
import themeLight from 'shikiji/themes/light-plus.mjs'


export async function registerHighlighter() {
const highlighter = await getHighlighterCore({
themes: [themeDark, themeLight],
langs: [langVue],
loadWasm: getWasmInlined
loadWasm: getWasmInlined,
tachibana-shin marked this conversation as resolved.
Show resolved Hide resolved
})
monaco.languages.register({ id: 'vue' })
shikijiToMonaco(highlighter, monaco)
return {
light: themeLight.name!,
dark: themeDark.name!
dark: themeDark.name!,
}
}