npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

vue3-ace-editor

v2.2.4

Published

Like vue2-ace-editor but more functional and supports Vue 3

Downloads

34,723

Readme

vue3-ace-editor

npm

A packaging of ace. Inspired by vue2-ace-editor, but supports Vue 3

How to use

  1. Install

    yarn add vue3-ace-editor
  2. Register it in components of Vue options

    import { VAceEditor } from 'vue3-ace-editor';
    
    export default {
        data,
        methods,
        ...
        components: {
            VAceEditor,
        },
    }
  3. 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

Deferences with vue2-ace-editor

  1. This component uses ace-builds directly, instead of the outdated wrapper brace
  2. DOM size changes are detected automatically using ResizeObserver, thus no width / height props needed.
  3. For easier usage, more props / events added / emitted.
    1. Prop readonly: This Boolean attribute indicates that the user cannot modify the value of the control.
    2. Prop placeholder: A hint to the user of what can be entered in the control.
    3. Prop wrap: Indicates whether the control wraps text.
    4. Prop printMargin: A short hand of showPrintMargin and printMarginColumn.
    5. Prop minLines and maxLines: Specifiy the minimum and maximum number of lines.
    6. All ace events emitted. Docs can be found here: https://ace.c9.io/#api=editor&nav=api
    7. Some commonly used methods focus, blur, selectAll provided as shortcuts.

Enable syntax checking

To enable syntax checking, module ace/mode/lang_worker must be registered, and option useWorker: true must be set.

Take JSON for example:

import workerJsonUrl from 'ace-builds/src-noconflict/worker-json?url'; // For vite

import workerJsonUrl from 'file-loader?esModule=false!ace-builds/src-noconflict/worker-json.js'; // For webpack / vue-cli

ace.config.setModuleUrl('ace/mode/json_worker', workerJsonUrl);
<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

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-json';
import 'ace-builds/src-noconflict/theme-chrome';

To use dynamic loading to avoid first-load overhead

import ace from 'ace-builds';

import modeJsonUrl from 'ace-builds/src-noconflict/mode-json?url';
ace.config.setModuleUrl('ace/mode/json', modeJsonUrl);

import themeChromeUrl from 'ace-builds/src-noconflict/theme-chrome?url';
ace.config.setModuleUrl('ace/theme/chrome', themeChromeUrl);

Find all supported themes and modes in node_modules/ace-builds/src-noconflict

Minimal example using vite

LICENSE

MIT