Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 Support CSS custom properties in createCursor #95

Merged
merged 1 commit into from
Jan 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# 4.0.4
- Support CSS custom properties as input for the `createCursor` method by applying fade via `opacity` instead of modifying the alpha channel.

# 4.0.3
- Make event listeners passive

Expand Down
4 changes: 1 addition & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "quill-cursors",
"version": "4.0.3",
"version": "4.0.4",
"description": "A multi cursor module for Quill.",
"keywords": [
"quill",
Expand Down Expand Up @@ -30,7 +30,6 @@
"@reedsy/eslint-plugin": "^0.14.2",
"@testing-library/jest-dom": "^5.16.1",
"@types/jest": "^27.4.0",
"@types/tinycolor2": "^1.4.3",
"@typescript-eslint/eslint-plugin": "^5.49.0",
"@typescript-eslint/parser": "^5.49.0",
"clean-webpack-plugin": "^4.0.0",
Expand All @@ -44,7 +43,6 @@
"sass": "^1.49.7",
"sass-loader": "^12.4.0",
"style-loader": "^3.3.1",
"tinycolor2": "^1.4.2",
"ts-jest": "^27.1.3",
"ts-loader": "^9.2.6",
"typescript": "^4.5.5",
Expand Down
6 changes: 4 additions & 2 deletions src/quill-cursors/cursor.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -234,13 +234,15 @@ describe('Cursor', () => {
expect(selections.children[0]).toHaveStyle('left: 50px');
expect(selections.children[0]).toHaveStyle('width: 100px');
expect(selections.children[0]).toHaveStyle('height: 200px');
expect(selections.children[0]).toHaveStyle('background-color: rgba(255, 0, 0, 0.3)');
expect(selections.children[0]).toHaveStyle('background-color: red');
expect(selections.children[0]).toHaveStyle('opacity: 0.3');

expect(selections.children[1]).toHaveStyle('top: 1000px');
expect(selections.children[1]).toHaveStyle('left: 1050px');
expect(selections.children[1]).toHaveStyle('width: 200px');
expect(selections.children[1]).toHaveStyle('height: 300px');
expect(selections.children[1]).toHaveStyle('background-color: rgba(255, 0, 0, 0.3)');
expect(selections.children[1]).toHaveStyle('background-color: red');
expect(selections.children[1]).toHaveStyle('opacity: 0.3');
});

it('clears the selection if nothing is passed in', () => {
Expand Down
4 changes: 2 additions & 2 deletions src/quill-cursors/cursor.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import IQuillCursorsOptions from './i-quill-cursors-options';
import IQuillRange from './i-range';
import tinycolor = require('tinycolor2');
import {ICoordinates} from './i-coordinates';

export default class Cursor {
Expand Down Expand Up @@ -171,7 +170,8 @@ export default class Cursor {
element.style.left = `${selection.left - container.left}px`;
element.style.width = `${selection.width}px`;
element.style.height = `${selection.height}px`;
element.style.backgroundColor = tinycolor(this.color).setAlpha(0.3).toString();
element.style.backgroundColor = this.color;
element.style.opacity = '0.3';

return element;
}
Expand Down
Loading