https://github.com/y-js/y-selections
Selections type for Yjs
https://github.com/y-js/y-selections
Last synced: 2 months ago
JSON representation
Selections type for Yjs
- Host: GitHub
- URL: https://github.com/y-js/y-selections
- Owner: y-js
- License: mit
- Created: 2015-04-07T03:11:07.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2015-05-29T09:21:01.000Z (almost 10 years ago)
- Last Synced: 2025-02-19T08:11:37.842Z (3 months ago)
- Language: JavaScript
- Size: 3.3 MB
- Stars: 1
- Watchers: 8
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# Selections Type for [Yjs](https://github.com/y-js/yjs)
Manage selections on y-list objects with this shareable type.
## Use it!
Retrieve this with bower or npm.##### Bower
```
bower install y-selections --save
```and include the js library.
```
```
##### NPM
```
npm install y-selections --save
```
and put it on the `Y` object.```
Y.Selections = require("y-selections");
```### Selections Object
##### Reference
* Create
```
var ysel = new Y.Selections()
```
* .select(from, to, attrs)
* Assign a set of attributes to a range. This method expects *references* (see y-list documentation) as the first two parameters (from, and to), and *attrs* should be an _Object_. Make sure that *from* is a predecessor of *to*!
* .unselect(from, to, attrs)
* Remove a set of attributes from a range. This method expects *references* (see y-list documentation) as the first two parametrs (from, and to), and *attrs* should be an _Array_. Make sure that *from* is a predecessor of *to*!
* .unselectAll(from, to)
* Remove all attributes from a range. This method expects *references* (see y-list documentation) as the first two parametrs (from, and to). Make sure that *from* is a predecessor of *to*!
* .observe(f)
* The observer is called whenever something on this text object changed. (throws select, and unselect events)
* .unobserve(f)
* Delete an observer## License
Yjs and y-selections are licensed under the [MIT License](./LICENSE.txt).