vue3-ace-editor
A packaging of ace. Inspired by vue2-ace-editor, but supports Vue 3
How to use
-
Install
yarn add vue3-ace-editor
-
Register it in components
of Vue options
import { VAceEditor } from 'vue3-ace-editor';
export default {
data,
methods,
...
components: {
VAceEditor,
},
}
-
Use the component in template
<v-ace-editor
v-model:value="content"
@init="editorInit"
lang="html"
theme="chrome"
style="height: 300px" />
prop v-model:value
is required. <v-ace-editor>
has no height by default. Its height must be specified manually, or set both min-lines
and max-lines
to make the editor's height auto-grow.
prop lang
, theme
is same as ace-editor's doc
- This component uses ace-builds directly, instead of the outdated wrapper brace
- DOM size changes are detected automatically using ResizeObserver, thus no
width
/ height
props needed. - For easier usage, more props / events added / emitted.
- Prop
readonly
: This Boolean attribute indicates that the user cannot modify the value of the control. - Prop
placeholder
: A hint to the user of what can be entered in the control. - Prop
wrap
: Indicates whether the control wraps text. - Prop
printMargin
: A short hand of showPrintMargin
and printMarginColumn
. - Prop
minLines
and maxLines
: Specifiy the minimum and maximum number of lines. - All ace events emitted. Docs can be found here: https://ace.c9.io/#api=editor&nav=api
- Some commonly used methods
focus
, blur
, selectAll
provided as shortcuts.
Breaking change
Using of ace-builds/webpack-resolver
is removed due to bug https://github.com/CarterLi/vue3-ace-editor/issues/3. You MUST import theme
and mode
yourself. eg.
import 'ace-builds/src-noconflict/mode-text';
import 'ace-builds/src-noconflict/theme-chrome';
Find all supported themes and modes in node_modules/ace-builds/src-noconflict
LICENSE
MIT