Gathering detailed insights and metrics for vue3-ace-editor
Gathering detailed insights and metrics for vue3-ace-editor
Gathering detailed insights and metrics for vue3-ace-editor
Gathering detailed insights and metrics for vue3-ace-editor
npm install vue3-ace-editor
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
199 Stars
37 Commits
25 Forks
4 Watching
2 Branches
3 Contributors
Updated on 28 Nov 2024
TypeScript (100%)
Cumulative downloads
Total Downloads
Last day
-12.1%
1,531
Compared to previous day
Last week
7.3%
8,954
Compared to previous week
Last month
11.9%
35,834
Compared to previous month
Last year
53.3%
383,395
Compared to previous year
A packaging of ace. Inspired by vue2-ace-editor, but supports Vue 3
ace-builds
must be installed alongside vue3-ace-editor
using your favorite package manager.
1<script setup> 2 import { ref } from 'vue'; 3 import { VAceEditor } from 'vue3-ace-editor'; 4 import 'ace-builds/src-noconflict/mode-json'; // Load the language definition file used below 5 import 'ace-builds/src-noconflict/theme-chrome'; // Load the theme definition file used below 6 7 const content = ref(JSON.stringify({ message: 'Hello Ace' })); 8</script> 9<template> 10 <v-ace-editor 11 v-model:value="content" 12 lang="json" 13 theme="chrome" 14 style="height: 300px" /> 15</template>
Property 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.
Property lang
, theme
is same as ace-editor's doc
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.
1// You MUST make sure that `ace-builds` or `vue3-ace-editor` (which imports `ace-builds` internally) is loaded before importing `mode` and `theme` 2import 'ace-builds/src-noconflict/mode-json'; 3import 'ace-builds/src-noconflict/theme-chrome';
To use dynamic loading to avoid first-load overhead
1import ace from 'ace-builds'; 2 3import modeJsonUrl from 'ace-builds/src-noconflict/mode-json?url'; 4ace.config.setModuleUrl('ace/mode/json', modeJsonUrl); 5 6import themeChromeUrl from 'ace-builds/src-noconflict/theme-chrome?url'; 7ace.config.setModuleUrl('ace/theme/chrome', themeChromeUrl);
Note that to make search box (Ctrl+F
or Command+F
) work, ext-searchbox
must also be loaded.
1import extSearchboxUrl from 'ace-builds/src-noconflict/ext-searchbox?url';
2ace.config.setModuleUrl('ace/ext/searchbox', extSearchboxUrl);
Find all supported themes and modes in node_modules/ace-builds/src-noconflict
width
/ height
props needed.readonly
: This Boolean attribute indicates that the user cannot modify the value of the control.placeholder
: A hint to the user of what can be entered in the control.wrap
: Indicates whether the control wraps text.printMargin
: A short hand of showPrintMargin
and printMarginColumn
.minLines
and maxLines
: Specifiy the minimum and maximum number of lines.focus
, blur
, selectAll
provided as shortcuts.Use getAceInstance
1<script setup> 2 import { ref, onMounted } from 'vue'; 3 4 const aceRef = ref(null); 5 6 onMounted(() => { 7 console.log(aceRef.value.getAceInstance()); 8 }) 9</script> 10<template> 11 <v-ace-editor ref="aceRef" v-bind="..." /> 12</template>
@init
is provided for vue2-ace-editor
compatibility only but is not recommanded to use.
To enable syntax checking, module ace/mode/lang_worker
must be registered, and option useWorker: true
must be set.
Take JSON for example:
1import workerJsonUrl from 'ace-builds/src-noconflict/worker-json?url'; // For vite 2 3import workerJsonUrl from 'file-loader?esModule=false!ace-builds/src-noconflict/worker-json.js'; // For webpack / vue-cli 4 5ace.config.setModuleUrl('ace/mode/json_worker', workerJsonUrl);
1<v-ace-editor v-model:value="json" lang="json" :options="{ useWorker: true }" />
See also https://github.com/CarterLi/vue3-ace-editor/issues/3#issuecomment-768190528 to load the worker file from CDN
Since ace doesn't support SSR, using it with Nuxt can be tricky. You must make sure that ace
related things are loaded only at client side.
1<script setup> 2import { markRaw, onMounted, ref } from 'vue'; 3 4const VAceEditor = ref('div'); // Stores dynamic loaded component. Before `vue3-ace-editor` is loaded, a `div` is used as a placeholder 5const content = ref(JSON.stringify({ platform: 'Nuxt', env: 'SSR' }, null, 2)); 6 7onMounted(async () => { // onMounted is a client-only lifecycle hook 8 await import('ace-builds'); // To importing things in a function, dynamic import must be used 9 await import('ace-builds/src-noconflict/mode-json'); 10 await import('ace-builds/src-noconflict/theme-chrome'); 11 VAceEditor.value = markRaw((await import('vue3-ace-editor')).VAceEditor); 12}); 13</script> 14<template> 15 <div> 16 <component :is="VAceEditor" v-model:value="content" lang="json" theme="chrome" style="height: 400px" /> 17 <textarea :value="content" style="width: 100%; margin-top: 10px" rows="5" /> 18 </div> 19</template>
Full example: https://stackblitz.com/edit/github-oeoxgm?file=app.vue
MIT
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
0 existing vulnerabilities detected
Reason
Found 2/30 approved changesets -- score normalized to 0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2024-11-25
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More