Skip to content

Commit

Permalink
fix(types): fix editor prop types
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 committed Nov 30, 2023
1 parent 812730d commit 828f202
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 14 deletions.
16 changes: 4 additions & 12 deletions src/editor/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import { type FunctionalComponent } from 'vue'
import CodeMirrorEditor from "./CodeMirrorEditor.vue";
import MonacoEditor from "./MonacoEditor.vue";

export type EditorComponentType = typeof CodeMirrorEditor | typeof MonacoEditor

export type PreviewMode = 'js' | 'css' | 'ssr'

Expand All @@ -12,14 +15,3 @@ export interface EditorProps {
export interface EditorEmits {
(e: 'change', code: string): void
}

export type EditorComponentType = FunctionalComponent<
EditorProps,
{ change: (code: string) => void }
> & {
editorType: 'monaco' | 'codemirror'
}

declare const EditorComponent: EditorComponentType

export default EditorComponent
3 changes: 1 addition & 2 deletions test/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { createApp, h, watchEffect } from 'vue'
import { Repl, ReplStore } from '../src'
import MonacoEditor from '../src/editor/MonacoEditor.vue'
// import CodeMirrorEditor from '../src/editor/CodeMirrorEditor.vue'
import { EditorComponentType } from '../src/editor/types'
;(window as any).process = { env: {} }

const App = {
Expand Down Expand Up @@ -43,7 +42,7 @@ const App = {
h(Repl, {
store,
theme: 'dark',
editor: MonacoEditor as any as EditorComponentType,
editor: MonacoEditor,
// layout: 'vertical',
ssr: true,
sfcOptions: {
Expand Down

0 comments on commit 828f202

Please sign in to comment.