Skip to content

Commit bc3898e

Browse files
committed
removes cjs references
1 parent bb2b17f commit bc3898e

7 files changed

Lines changed: 287 additions & 21 deletions

File tree

.eslintrc.json

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,15 @@
1818
},
1919
"settings": {
2020
"import/resolver": {
21-
"node": {
22-
"extensions": [".js", ".jsx", ".ts", ".tsx"]
23-
}
21+
"typescript": true
2422
}
2523
},
26-
"plugins": ["react", "jest", "@typescript-eslint", "prettier"],
24+
"plugins": [
25+
"react",
26+
"jest",
27+
"@typescript-eslint",
28+
"prettier"
29+
],
2730
"rules": {
2831
"import/extensions": "off",
2932
"react/require-default-props": "off",
@@ -34,7 +37,14 @@
3437
"unnamedComponents": "arrow-function"
3538
}
3639
],
37-
"react/jsx-filename-extension": ["error", { "extensions": [".tsx"] }],
40+
"react/jsx-filename-extension": [
41+
"error",
42+
{
43+
"extensions": [
44+
".tsx"
45+
]
46+
}
47+
],
3848
"@typescript-eslint/no-explicit-any": [
3949
"off",
4050
{
@@ -44,6 +54,11 @@
4454
],
4555
"import/prefer-default-export": "off",
4656
"import/no-default-export": "error",
47-
"import/no-extraneous-dependencies": ["error", { "devDependencies": true }]
57+
"import/no-extraneous-dependencies": [
58+
"error",
59+
{
60+
"devDependencies": true
61+
}
62+
]
4863
}
49-
}
64+
}

e2e/webpack.config.cjs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ module.exports = {
1717

1818
resolve: {
1919
extensions: ['.js', '.jsx', '.ts', '.tsx'],
20+
extensionAlias: {
21+
'.js': ['.ts', '.tsx', '.js'],
22+
},
2023
},
2124

2225
plugins: [

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@huridocs/react-text-selection-handler",
3-
"version": "0.3.2",
3+
"version": "0.3.3",
44
"type": "module",
55
"main": "./dist/index.js",
66
"exports": {
@@ -55,6 +55,7 @@
5555
"eslint": "^8.57.0",
5656
"eslint-config-airbnb": "^19.0.4",
5757
"eslint-config-prettier": "^9.1.0",
58+
"eslint-import-resolver-typescript": "^4.4.4",
5859
"eslint-plugin-import": "^2.29.1",
5960
"eslint-plugin-jasmine": "^4.1.3",
6061
"eslint-plugin-jest": "^27.9.0",

src/HandleTextSelection.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import React, { FunctionComponent, useRef, useEffect } from 'react';
2-
import { elementContainsDomRect } from './elementContainsDomRect';
3-
import { rangeToTextRects } from './rangeToTextRects';
4-
import { domRectToSelectionRectangle, TextSelection } from './TextSelection';
5-
import { getSelectedText } from './getSelectedText';
2+
import { elementContainsDomRect } from './elementContainsDomRect.js';
3+
import { rangeToTextRects } from './rangeToTextRects.js';
4+
import { domRectToSelectionRectangle, TextSelection } from './TextSelection.js';
5+
import { getSelectedText } from './getSelectedText.js';
66

77
interface SelectionHandlerProps {
88
onSelect: (textSelection: TextSelection) => any;
@@ -24,7 +24,7 @@ const normalizedFirefoxRange = (selection: Selection) => {
2424

2525
const HandleTextSelection: FunctionComponent<SelectionHandlerProps> = ({
2626
onSelect,
27-
onDeselect = () => {},
27+
onDeselect = () => { },
2828
children,
2929
}) => {
3030
const ref = useRef<HTMLDivElement>(null);
@@ -60,7 +60,7 @@ const HandleTextSelection: FunctionComponent<SelectionHandlerProps> = ({
6060
const refElement = ref.current;
6161

6262
if (!refElement) {
63-
return () => {};
63+
return () => { };
6464
}
6565

6666
const handleKeyDown = (event: KeyboardEvent) => {

src/Highlight.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React, { CSSProperties, FunctionComponent, useContext } from 'react';
2-
import { SelectionRegionContext } from './SelectionRegion';
3-
import { TextSelection } from './TextSelection';
2+
import { SelectionRegionContext } from './SelectionRegion.js';
3+
import { TextSelection } from './TextSelection.js';
44

55
interface HighlightProps {
66
textSelection: TextSelection;

src/index.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export { Highlight } from './Highlight';
2-
export { HandleTextSelection } from './HandleTextSelection';
3-
export { SelectionRegion } from './SelectionRegion';
4-
export type { TextSelection, SelectionRectangle } from './TextSelection';
1+
export { Highlight } from './Highlight.js';
2+
export { HandleTextSelection } from './HandleTextSelection.js';
3+
export { SelectionRegion } from './SelectionRegion.js';
4+
export type { TextSelection, SelectionRectangle } from './TextSelection.js';

0 commit comments

Comments
 (0)