Skip to content

Commit

Permalink
Convert to TypeScript + add definitions on build (#83)
Browse files Browse the repository at this point in the history
* Converted to TypeScript
  • Loading branch information
beaudry committed Aug 25, 2022
1 parent 61bac0f commit 1c7b621
Show file tree
Hide file tree
Showing 7 changed files with 260 additions and 23 deletions.
30 changes: 30 additions & 0 deletions dist/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { Options as NormalizeUrlOptions } from 'normalize-url';
import Quill from 'quill';
declare global {
interface Window {
Quill?: typeof Quill;
}
}
export declare type MagicUrlOptions = {
globalRegularExpression: RegExp;
urlRegularExpression: RegExp;
globalMailRegularExpression: RegExp;
mailRegularExpression: RegExp;
normalizeRegularExpression: RegExp;
normalizeUrlOptions: NormalizeUrlOptions;
};
export declare type Normalizer = (stringToNormalize: string) => string;
export default class MagicUrl {
quill: Quill;
options: MagicUrlOptions;
urlNormalizer: Normalizer;
mailNormalizer: Normalizer;
constructor(quill: Quill, options?: Partial<MagicUrlOptions>);
registerPasteListener(): void;
registerTypeListener(): void;
registerBlurListener(): void;
checkTextForUrl(triggeredByInlineWhitespace?: boolean): void;
handleMatches(leafIndex: number, text: string, matches: RegExpMatchArray, normalizer: Normalizer): void;
updateText(index: number, string: string, normalizer: Normalizer): void;
normalize(url: string): string;
}
3 changes: 1 addition & 2 deletions dist/index.js

Large diffs are not rendered by default.

179 changes: 170 additions & 9 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 7 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@
"version": "4.1.7",
"description": "Checks for URLs during typing and pasting and automatically converts them to links.",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"babel": {
"presets": [
"@babel/preset-env"
"@babel/preset-env",
"@babel/preset-typescript"
]
},
"scripts": {
"build": "webpack -p --progress --colors",
"build": "webpack -p --progress --colors & tsc --build",
"dev": "webpack-dev-server --progress --colors",
"test": "jest",
"test:e2e": "npm run dev & cypress open"
Expand All @@ -35,17 +37,20 @@
"devDependencies": {
"@babel/core": "^7.7.4",
"@babel/preset-env": "^7.9.6",
"@babel/preset-typescript": "^7.18.6",
"@types/jest": "^26.0.24",
"babel-loader": "^8.1.0",
"babel-preset-env": "^1.7.0",
"cypress": "^7.7.0",
"eslint-plugin-jest": "^24.3.6",
"jest": "^26.6.3",
"typescript": "^4.7.4",
"webpack": "^4.41.2",
"webpack-cli": "^3.0.8",
"webpack-dev-server": "^3.11.0"
},
"dependencies": {
"@types/quill": "^2.0.9",
"normalize-url": "^4.5.1",
"quill-delta": "^3.6.2"
}
Expand Down

0 comments on commit 1c7b621

Please sign in to comment.