Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
vue-contenteditable
Advanced tools
This plugin provides a `<contenteditable/>` element supporting `v-model`. It also provides some (optional) features, like preventing html input and paste, or new lines.
This plugin provides a <contenteditable/>
element supporting v-model
. It also provides some (optional) features, like preventing html input and paste, or new lines.
It is inpired by the nice (but limited by design) https://github.com/asconwe/vue-contenteditable-directive .
Contrary to vue-contenteditable-directive
, this plugin has full support of v-model reactivity.
New in version 3.0.0 : Typescript support !
The response is generally NO.
But... there are edge cases where neither <input/>
nor <textarea>
could suit, for example when you need a dynamic object size to adapt to user input text size.
NODE : Version 3.0.0 is only compatible with VueJS v3+. For VueJS v2, please install the version 1.0.2.
npm install --save vue-contenteditable
or
yarn add vue-contenteditable
In your main.js
:
import contenteditable from 'vue-contenteditable'
Vue.use(contenteditable)
Or simply register in the components
field of each component using it.
The needed files are already provided in dist/
, but if you want to re-build, simlply run :
(To install the dependencies)
yarn
Due to a limitation in the vue cli plugin order, you have to manually edit the package.json
to put the lines :
"@hl037/vue-cli-plugin-ts-bundler": "hl037/vue-cli-plugin-ts-bundler.git"
At the end of the "devDependencies" object
yarn build
yarn bundleDts
The last command is for typescript support.
<script src="contenteditable.min.js"></script>
<template>
<contenteditable tag="div" :contenteditable="isEditable" v-model="message" :noNL="true" :noHTML="true" @returned="enterPressed" />
</template>
<script>
export default {
data() {
return {
isEditable: true,
message: "hello"
}
},
methods : {
enterPressed(){
alert('Enter Pressed');
}
}
}
For advance usages, please refer to the samples provided in the git repository. There is an example written in ts and one in js. These samples demonstrate all the the features of the component.
Prop name | Type | Default | Description |
---|---|---|---|
tag | String | "div" | Html element type (p , div ...) |
v-model | String | v-model as usually used with <input/> and <textarea/> | |
contenteditable | Boolean | true | Forwarded to DOM's contenteditable https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/contentEditable. |
noHTML | Boolean | true | Prevent insertion (either typed or pasted) of html text |
noNL | Boolean | false | Prevent insertion of new-lines. Also activate returned event emission |
returned
When the user press ⏎ and noNL
is set, then it emits the returned
event with the current value (as a String
) as argument.
All js events on the element can be transparantly listened to (the sample projects provide an example).
This code is provided as-is, under the terms of the MIT license (see License file for more details).
A link to the original sources and contribution / pull request is welcome if you enjoy / use / contribute to this module ! :)
FAQs
This plugin provides a `<contenteditable/>` element supporting `v-model`. It also provides some (optional) features, like preventing html input and paste, or new lines.
The npm package vue-contenteditable receives a total of 5,437 weekly downloads. As such, vue-contenteditable popularity was classified as popular.
We found that vue-contenteditable demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.