timdown / rangy

A cross-browser JavaScript range and selection library.
MIT License
2.25k stars 367 forks source link

Using rangy with Vue.js #444

Open JustinMontes opened 6 years ago

JustinMontes commented 6 years ago

Once installed via: npm i rangy

The syntax is not clear to my team when say calling the highlighter function. We're new to Vue.js and are experiencing a lot of compilation issues when calling these functions.

yangzhixiao commented 6 years ago

jsut install it by "npm install rangy --save", then import in xx.vue file like "import rangy from 'rangy';", and you can use the rangy object. just use it as a module in vue.js, var rangy = require('rangy'); also available.

tsaltena commented 6 years ago

I was successful in implementing it through following: https://vuejsdevelopers.com/2017/04/22/vue-js-libraries-plugins/

including:

import rangy from 'rangy';
Object.defineProperty(Vue.prototype, '$rangy', { value: rangy });

then makes Rangy available as this.$rangy etc.