quill-cursors
Advanced tools
Comparing version 0.0.1 to 0.0.2
{ | ||
"name": "quill-cursors", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"description": "A multi cursor module for Quill.", | ||
@@ -23,9 +23,17 @@ "keywords": [ | ||
"devDependencies": { | ||
"css-loader": "^0.28.0", | ||
"extract-text-webpack-plugin": "^2.1.0", | ||
"node-sass": "^4.5.2", | ||
"normalize.css": "^6.0.0", | ||
"quill": "^1.2.3", | ||
"webpack": "^2.3.3", | ||
"sass-loader": "^6.0.3", | ||
"style-loader": "^0.16.1", | ||
"uglifyjs-webpack-plugin": "^0.4.2", | ||
"webpack": "^2.4.1", | ||
"webpack-dev-server": "^2.4.2" | ||
}, | ||
"dependencies": { | ||
"rangefix": "^0.2.3" | ||
"rangefix": "^0.2.3", | ||
"tinycolor2": "^1.4.1" | ||
} | ||
} |
@@ -30,8 +30,34 @@ # quill-cursors | ||
modules: { | ||
'cursors': { /* add your configuration here */ }, | ||
'cursors': true, | ||
} | ||
}); | ||
editor.registerTextChangeListener(); | ||
</script> | ||
</body> | ||
``` | ||
``` | ||
To set a multicursor call: | ||
``` | ||
editor.getModule('cursors').set({ | ||
id: '1', | ||
name: 'User 1', | ||
color: 'red', | ||
range: range | ||
}); | ||
``` | ||
For more info check out [the included example](example). | ||
## Development | ||
Run `npm run build` to package a build and `npm run start` to build, start the example webserver and watch for changes. | ||
## TODO | ||
A few things that can be improved: | ||
* Add tests | ||
* Improve bundling, namely on styles/add minified styles |
@@ -1,3 +0,4 @@ | ||
import RangeFix from 'rangefix/rangefix'; | ||
import Quill from 'Quill'; | ||
import Quill from 'quill'; | ||
import 'rangefix/rangefix'; | ||
import tinycolor from 'tinycolor2'; | ||
@@ -214,3 +215,3 @@ var DEFAULT_OPTIONS = { | ||
range.setEnd(endLeaf[0].domNode, endLeaf[1]); | ||
rects = RangeFix.getClientRects(range); | ||
rects = window.RangeFix.getClientRects(range); | ||
@@ -256,21 +257,21 @@ this._updateCaret(cursor, endLeaf, containerRect); | ||
} | ||
}; | ||
// Wipe the slate clean | ||
cursor.selectionEl.innerHTML = null; | ||
// Wipe the slate clean | ||
cursor.selectionEl.innerHTML = null; | ||
var index = []; | ||
var rectIndex; | ||
var index = []; | ||
var rectIndex; | ||
[].forEach.call(rects, function(rect) { | ||
rectIndex = ('' + rect.top + rect.left + rect.width + rect.height); | ||
[].forEach.call(rects, function(rect) { | ||
rectIndex = ('' + rect.top + rect.left + rect.width + rect.height); | ||
// Note: Safari throws a rect with length 1 when caret with no selection. | ||
// A check was addedfor to avoid drawing those carets - they show up on blinking. | ||
if (!~index.indexOf(rectIndex) && rect.width > 1) { | ||
index.push(rectIndex); | ||
cursor.selectionEl.appendChild(createSelectionBlock(rect)); | ||
} | ||
}, this); | ||
// Note: Safari throws a rect with length 1 when caret with no selection. | ||
// A check was addedfor to avoid drawing those carets - they show up on blinking. | ||
if (!~index.indexOf(rectIndex) && rect.width > 1) { | ||
index.push(rectIndex); | ||
cursor.selectionEl.appendChild(createSelectionBlock(rect)); | ||
} | ||
}, this); | ||
}; | ||
Quill.register('modules/cursors', CursorsModule); | ||
Quill.register('modules/cursors', CursorsModule); |
var path = require('path'); | ||
var UglifyJSPlugin = require('uglifyjs-webpack-plugin'); | ||
var ExtractTextPlugin = require('extract-text-webpack-plugin'); | ||
module.exports = { | ||
entry: './src/cursors.js', | ||
output: { | ||
filename: 'quill-cursors.js', | ||
path: path.resolve(__dirname, 'dist') | ||
}, | ||
devServer: { | ||
contentBase: path.join(__dirname, 'example') | ||
} | ||
}; | ||
var moduleBundle = { | ||
entry: { | ||
'quill-cursors': ['./src/cursors.js', './src/cursors.scss'], | ||
'quill-cursors.min': ['./src/cursors.js'], | ||
}, | ||
output: { | ||
filename: '[name].js', | ||
path: path.resolve(__dirname, 'dist') | ||
}, | ||
externals: { | ||
quill: 'Quill' | ||
}, | ||
module: { | ||
rules: [{ | ||
test: /\.scss$/, | ||
loader: ExtractTextPlugin.extract(['css-loader', 'sass-loader']) | ||
}] | ||
}, | ||
plugins: [ | ||
new UglifyJSPlugin({ | ||
include: /\.min\.js$/, | ||
}), | ||
new ExtractTextPlugin({ // define where to save the file | ||
filename: '[name].css' | ||
}) | ||
], | ||
devServer: { | ||
contentBase: [ | ||
path.join(__dirname, 'example'), | ||
path.join(__dirname, 'dist'), | ||
path.join(__dirname, 'node_modules/normalize.css'), | ||
path.join(__dirname, 'node_modules/quill/dist') | ||
] | ||
}, | ||
}; | ||
module.exports = [moduleBundle]; |
Sorry, the diff of this file is not supported yet
16458
11
314
63
2
10
+ Addedtinycolor2@^1.4.1
+ Addedtinycolor2@1.6.0(transitive)