-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #185 from qianmoQ/feature-components
refactor and feat code editor
- Loading branch information
Showing
19 changed files
with
1,095 additions
and
352 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,183 @@ | ||
--- | ||
title: Shadcn CodeEditor | ||
--- | ||
|
||
# Introduction | ||
|
||
This document describes the features and usage of the ShadcnCodeEditor component. | ||
|
||
## Usage | ||
|
||
::: raw | ||
|
||
<CodeRunner title="Usage"> | ||
<ShadcnCodeEditor v-model="value" /> | ||
</CodeRunner> | ||
|
||
::: | ||
|
||
::: details Show code | ||
|
||
```vue | ||
<template> | ||
<ShadcnCodeEditor v-model="value" /> | ||
</template> | ||
``` | ||
|
||
::: | ||
|
||
## Height | ||
|
||
::: raw | ||
|
||
<CodeRunner title="Height"> | ||
<ShadcnCodeEditor v-model="value" :height="216" /> | ||
</CodeRunner> | ||
|
||
::: | ||
|
||
::: details Show code | ||
|
||
```vue | ||
<template> | ||
<ShadcnCodeEditor v-model="value" :height="216" /> | ||
</template> | ||
``` | ||
|
||
::: | ||
|
||
## Config | ||
|
||
::: raw | ||
|
||
<CodeRunner title="Config"> | ||
<ShadcnCodeEditor v-model="value" :config="{language: 'javascript'}" /> | ||
</CodeRunner> | ||
|
||
::: | ||
|
||
::: details Show code | ||
|
||
```vue | ||
<template> | ||
<ShadcnCodeEditor v-model="value" :config="{language: 'javascript'}" /> | ||
</template> | ||
``` | ||
|
||
::: | ||
|
||
## Auto Completion | ||
|
||
::: raw | ||
|
||
<CodeRunner title="Auto Completion"> | ||
<ShadcnCodeEditor v-model="value" | ||
:auto-complete-config="{ | ||
endpoint: 'http://jsonplaceholder.typicode.com/posts', | ||
method: 'GET', | ||
trigger: ['.', '@'], | ||
transform: (data: any) => { | ||
return data.map((item: any) => ({ | ||
label: item.title, | ||
insertText: item.body, | ||
detail: item.title | ||
})) | ||
}, | ||
// requestParams: (context) => ({ | ||
// word: context.word, | ||
// line: context.position.lineNumber.toString() | ||
// }), | ||
// requestBody: (context) => ({ | ||
// code: context.modelValue, | ||
// position: context.position | ||
// }) | ||
}"/> | ||
</CodeRunner> | ||
|
||
::: | ||
|
||
::: details Show code | ||
|
||
```vue | ||
<ShadcnCodeEditor v-model="value" | ||
:auto-complete-config="{ | ||
endpoint: 'http://jsonplaceholder.typicode.com/posts', | ||
method: 'GET', | ||
trigger: ['.', '@'], | ||
transform: (data: any) => { | ||
return data.map((item: any) => ({ | ||
label: item.title, | ||
insertText: item.body, | ||
detail: item.title | ||
})) | ||
}, | ||
// requestParams: (context) => ({ | ||
// word: context.word, | ||
// line: context.position.lineNumber.toString() | ||
// }), | ||
// requestBody: (context) => ({ | ||
// code: context.modelValue, | ||
// position: context.position | ||
// }) | ||
}"/> | ||
``` | ||
|
||
::: | ||
|
||
## Context Menu | ||
|
||
::: raw | ||
|
||
<CodeRunner title="Context Menu"> | ||
<ShadcnCodeEditor v-model="value" | ||
:context-menu-config="{ | ||
showDefaultItems: true, | ||
items: [{ | ||
label: 'Format Code', | ||
icon: 'Save', | ||
action: ({ editor, selection}) => { | ||
console.log(editor.getModel()?.getValueInRange(selection)) | ||
} | ||
}] | ||
}"/> | ||
</CodeRunner> | ||
|
||
::: | ||
|
||
::: details Show code | ||
|
||
```vue | ||
<ShadcnCodeEditor v-model="value" | ||
:context-menu-config="{ | ||
showDefaultItems: true, | ||
items: [{ | ||
label: 'Format Code', | ||
icon: 'Save', | ||
action: ({ editor, selection}) => { | ||
console.log(editor.getModel()?.getValueInRange(selection)) | ||
} | ||
}] | ||
}"/> | ||
``` | ||
|
||
::: | ||
|
||
## CodeEditor Props | ||
|
||
<ApiTable title="Props" | ||
:headers="['Attribute', 'Description', 'Type', 'Default Value', 'List']" | ||
:columns="[ | ||
['modelValue', 'modelValue value', 'string', '-', '-'], | ||
['height', 'height value', 'number', '300', '-'], | ||
['config', 'see monaco.editor.IStandaloneEditorConstructionOptions', 'any', '{}', '-'], | ||
['autoCompleteConfig', 'see CodeEditorAutoCompleteProps', 'any', '{}', '-'], | ||
['contextMenuConfig', 'see CodeEditorContextMenuProps', 'any', '{}', '-'], | ||
]"> | ||
</ApiTable> | ||
|
||
|
||
<script setup lang="ts"> | ||
import { ref } from 'vue'; | ||
|
||
const value = ref('Hello View Shadcn UI') | ||
</script> |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.