diff --git a/.eslintrc.yaml b/.eslintrc.yaml index 8905f3d4..9e030321 100644 --- a/.eslintrc.yaml +++ b/.eslintrc.yaml @@ -16,3 +16,4 @@ rules: - ignoreRestSiblings: true argsIgnorePattern: '^_' '@typescript-eslint/no-explicit-any': 'error' + 'prettier/prettier': 'error' diff --git a/.gitattributes b/.gitattributes index 66763d68..5762a256 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,2 +1,4 @@ packages/jquery-textcomplete/dist/* linguist-vendored packages/jquery-textcomplete/src/vendor/* linguist-vendored + +* text=auto eol=lf diff --git a/.github/workflows/gh-pages.yaml b/.github/workflows/gh-pages.yaml index 26abc93f..1d6b9f99 100644 --- a/.github/workflows/gh-pages.yaml +++ b/.github/workflows/gh-pages.yaml @@ -6,12 +6,11 @@ jobs: publish: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - uses: actions/setup-node@v1 + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 with: - node-version: 12.x + node-version: 18.x - run: yarn install --no-lockfile - - run: yarn lerna bootstrap - run: yarn build - uses: peaceiris/actions-gh-pages@v3 with: diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml index 07cb997a..b19d7093 100644 --- a/.github/workflows/publish.yaml +++ b/.github/workflows/publish.yaml @@ -8,13 +8,12 @@ jobs: publish: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - uses: actions/setup-node@v1 + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 with: - node-version: 12.x + node-version: 18.x registry-url: https://registry.npmjs.org - run: yarn install --no-lockfile - - run: yarn lerna bootstrap - run: yarn build:packages - run: yarn lerna publish from-git --yes --no-push --no-git-tag-version env: diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index b839c733..c08c03c5 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -7,12 +7,11 @@ jobs: test: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - uses: actions/setup-node@v1 + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 with: - node-version: 14.x + node-version: 18.x - run: yarn install - - run: yarn lerna bootstrap - run: yarn build - run: yarn lint - run: yarn test diff --git a/.gitignore b/.gitignore index 6fdd76c2..5dccb765 100644 --- a/.gitignore +++ b/.gitignore @@ -5,5 +5,6 @@ yarn.lock package-lock.json .vscode/* !.vscode/textcomplete.code-workspace +.idea docs/.cache lerna-debug.log diff --git a/.prettierrc.yaml b/.prettierrc.yaml new file mode 100644 index 00000000..7d20c9a1 --- /dev/null +++ b/.prettierrc.yaml @@ -0,0 +1,2 @@ +trailingComma: 'es5' +semi: false diff --git a/README.md b/README.md index 32016613..3cd90893 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Textcomplete -> Autocomplete for HTMLTextAreaElement and more. +Autocomplete for HTMLTextAreaElement and more. ![Publish](https://github.com/yuku/textcomplete/workflows/Publish/badge.svg) ![Test](https://github.com/yuku/textcomplete/workflows/Test/badge.svg) @@ -8,27 +8,26 @@ ![](./docs/images/demo.gif) -[Document](https://yuku.takahashi.coffee/textcomplete/). +See more at [yuku.takahashi.coffee/textcomplete](https://yuku.takahashi.coffee/textcomplete/) ## Packages Textcomplete consists of subpackages: -Name | Description -------------------------------|------------------------------------------- -@textcomplete/core | Core of Textcomplete. -@textcomplete/textarea | Editor for HTMLTextAreaElement. -@textcomplete/contenteditable | Editor for contenteditable. (Experimental) -@textcomplete/codemirror | Editor for CodeMirror. (Experimental) -@textcomplete/utils | Utility functions for editors. +| Name | Description | +|-------------------------------|--------------------------------------------| +| @textcomplete/core | Core of Textcomplete. | +| @textcomplete/textarea | Editor for HTMLTextAreaElement. | +| @textcomplete/contenteditable | Editor for contenteditable. (Experimental) | +| @textcomplete/codemirror | Editor for CodeMirror. (Experimental) | +| @textcomplete/utils | Utility functions for editors. | ## Development -### View Document +### View documentation ```bash yarn install -yarn lerna bootstrap yarn docs ``` diff --git a/docs/package.json b/docs/package.json index eab49346..f8886d12 100644 --- a/docs/package.json +++ b/docs/package.json @@ -3,18 +3,18 @@ "private": true, "version": "0.1.12", "scripts": { - "build": "rm -fr dist cache && parcel build index.pug --public-url /textcomplete", - "format:eslint": "eslint --fix '**/*.ts' '**/*.tsx'", - "format:prettier": "prettier --write '**/*.ts' '**/*.tsx'", + "build": "rimraf dist .cache && parcel build index.pug --public-url /textcomplete", + "format:eslint": "eslint --fix **/*.ts **/*.tsx", + "format:prettier": "prettier --write **/*.ts **/*.tsx", "format": "run-s format:eslint format:prettier", - "lint": "eslint '**/*.ts' '**/*.tsx'", + "lint": "eslint **/*.ts **/*.tsx", "start": "parcel index.pug" }, "dependencies": { - "@textcomplete/codemirror": "^0.1.11", + "@textcomplete/codemirror": "^0.1.12", "@textcomplete/contenteditable": "^0.1.12", - "@textcomplete/core": "^0.1.11", - "@textcomplete/textarea": "^0.1.11", + "@textcomplete/core": "^0.1.12", + "@textcomplete/textarea": "^0.1.12", "codemirror": "^5.54.0", "prism-react-renderer": "^1.1.1", "react": "^17.0.2", @@ -23,9 +23,9 @@ "devDependencies": { "@types/react": "^17.0.3", "@types/react-dom": "^17.0.2", - "eslint": "^7.21.0", - "eslint-plugin-react": "^7.20.0", - "eslint-plugin-react-hooks": "^4.0.4", + "eslint": "^8.55.0", + "eslint-plugin-react": "^7.33.2", + "eslint-plugin-react-hooks": "^4.6.0", "parcel-bundler": "1.12.5", "pug": "^3.0.2", "sass": "^1.32.8" diff --git a/docs/sections/Editors.tsx b/docs/sections/Editors.tsx index 2de2d10f..0e358ac6 100644 --- a/docs/sections/Editors.tsx +++ b/docs/sections/Editors.tsx @@ -62,7 +62,7 @@ export const Editors: FC = ({ id }) => ( />
-

Contenteditable

+

Contenteditable

@textcomplete/contenteditable provides a textcomplete editor implementation for a contenteditable element. This package is diff --git a/lerna.json b/lerna.json index 2c8be1d1..e4632015 100644 --- a/lerna.json +++ b/lerna.json @@ -1,7 +1,6 @@ { "version": "0.1.12", "npmClient": "yarn", - "useWorkspaces": true, "command": { "version": { "ignoreChanges": [ @@ -14,5 +13,6 @@ "packages": [ "packages/textcomplete-*", "docs" - ] + ], + "$schema": "node_modules/lerna/schemas/lerna-schema.json" } diff --git a/package.json b/package.json index 53da9e79..71ea925f 100644 --- a/package.json +++ b/package.json @@ -16,20 +16,19 @@ "test": "lerna run test --parallel" }, "devDependencies": { - "@types/jest": "^27.0.1", - "@typescript-eslint/eslint-plugin": "^4.17.0", - "@typescript-eslint/parser": "^4.17.0", - "eslint": "^7.21.0", - "eslint-config-prettier": "^8.1.0", - "eslint-plugin-prettier": "^4.0.0", - "jest": "^27.2.0", - "lerna": "^3.22.1", + "@types/jest": "^29.5.10", + "@typescript-eslint/eslint-plugin": "^6.13.2", + "@typescript-eslint/parser": "^6.13.2", + "eslint": "^8.55.0", + "eslint-config-prettier": "^9.1.0", + "eslint-plugin-prettier": "^5.0.1", + "jest": "^29.7.0", + "jest-environment-jsdom": "~29.7.0", + "lerna": "^8.0.0", + "rimraf": "^5.0.5", "npm-run-all": "^4.1.5", - "prettier": "^2.0.5", - "ts-jest": "^27.0.5", - "typescript": "^4.4.3" - }, - "prettier": { - "semi": false + "prettier": "^3.1.0", + "ts-jest": "^29.1.1", + "typescript": "^5.3.2" } } diff --git a/packages/textcomplete-codemirror/README.md b/packages/textcomplete-codemirror/README.md index 0ded1986..0a627a9f 100644 --- a/packages/textcomplete-codemirror/README.md +++ b/packages/textcomplete-codemirror/README.md @@ -1,9 +1,11 @@ # @textcomplete/codemirror -> Textcomplete editor for CodeMirror. (Experimental) +Textcomplete editor for CodeMirror. (Experimental) [![npm version](https://badge.fury.io/js/@textcomplete%2Fcodemirror.svg)](http://badge.fury.io/js/@textcomplete%2Fcodemirror) +Check the live demo [here](https://yuku.takahashi.coffee/textcomplete/#textcomplete-codemirror). + ## Install ```bash diff --git a/packages/textcomplete-codemirror/package.json b/packages/textcomplete-codemirror/package.json index c35aebfb..529c63aa 100644 --- a/packages/textcomplete-codemirror/package.json +++ b/packages/textcomplete-codemirror/package.json @@ -9,19 +9,19 @@ "author": "Yuku Takahashi", "license": "MIT", "scripts": { - "build": "rm -fr dist && tsc", - "format:eslint": "eslint --fix 'src/**/*.ts'", - "format:prettier": "prettier --write 'src/**/*.ts'", + "build": "rimraf dist && tsc", + "format:eslint": "eslint --fix src/**/*.ts", + "format:prettier": "prettier --write src/**/*.ts", "format": "run-s format:eslint format:prettier", - "lint": "eslint 'src/**/*.ts'" + "lint": "eslint src/**/*.ts" }, "devDependencies": { - "@textcomplete/core": "^0.1.11", + "@textcomplete/core": "^0.1.12", "@types/codemirror": "^5.60.2", "codemirror": "^5.54" }, "peerDependencies": { - "@textcomplete/core": "^0.1.9", + "@textcomplete/core": "^0.1.12", "codemirror": "^5.54" }, "publishConfig": { diff --git a/packages/textcomplete-contenteditable/README.md b/packages/textcomplete-contenteditable/README.md index 0cae1236..a559ec1b 100644 --- a/packages/textcomplete-contenteditable/README.md +++ b/packages/textcomplete-contenteditable/README.md @@ -1,9 +1,10 @@ # @textcomplete/contenteditable -> Textcomplete editor for contenteditable. (Experimental) +Textcomplete editor for contenteditable. (Experimental) [![npm version](https://badge.fury.io/js/@textcomplete%2Fcontenteditable.svg)](http://badge.fury.io/js/@textcomplete%2Fcontenteditable) +Check the live demo [here](https://yuku.takahashi.coffee/textcomplete/#textcomplete-contenteditable). ## Install diff --git a/packages/textcomplete-contenteditable/package.json b/packages/textcomplete-contenteditable/package.json index be3291a6..3f554d25 100644 --- a/packages/textcomplete-contenteditable/package.json +++ b/packages/textcomplete-contenteditable/package.json @@ -9,20 +9,20 @@ "author": "Yuku Takahashi", "license": "MIT", "scripts": { - "build": "rm -fr dist && tsc", - "format:eslint": "eslint --fix 'src/**/*.ts'", - "format:prettier": "prettier --write 'src/**/*.ts'", + "build": "rimraf dist && tsc", + "format:eslint": "eslint --fix src/**/*.ts", + "format:prettier": "prettier --write src/**/*.ts", "format": "run-s format:eslint format:prettier", - "lint": "eslint 'src/**/*.ts'" + "lint": "eslint src/**/*.ts" }, "dependencies": { - "@textcomplete/utils": "^0.1.11" + "@textcomplete/utils": "^0.1.12" }, "devDependencies": { - "@textcomplete/core": "^0.1.11" + "@textcomplete/core": "^0.1.12" }, "peerDependencies": { - "@textcomplete/core": "^0.1.9" + "@textcomplete/core": "^0.1.12" }, "publishConfig": { "access": "public" diff --git a/packages/textcomplete-core/README.md b/packages/textcomplete-core/README.md index f85bb5b9..0c91547a 100644 --- a/packages/textcomplete-core/README.md +++ b/packages/textcomplete-core/README.md @@ -1,9 +1,11 @@ # @textcomplete/core -> Core of Textcomplete +Core of Textcomplete [![npm version](https://badge.fury.io/js/@textcomplete%2Fcore.svg)](http://badge.fury.io/js/@textcomplete%2Fcore) +Read more and check the live demo at [yuku.takahashi.coffee/textcomplete](https://yuku.takahashi.coffee/textcomplete/) + ## License © Yuku Takahashi - This software is licensed under the MIT license. diff --git a/packages/textcomplete-core/package.json b/packages/textcomplete-core/package.json index 8d502601..cd07d623 100644 --- a/packages/textcomplete-core/package.json +++ b/packages/textcomplete-core/package.json @@ -9,15 +9,15 @@ "author": "Yuku Takahashi", "license": "MIT", "scripts": { - "build": "rm -fr dist && tsc", - "format:eslint": "eslint --fix 'src/**/*.ts'", - "format:prettier": "prettier --write 'src/**/*.ts'", + "build": "rimraf dist && tsc", + "format:eslint": "eslint --fix src/**/*.ts", + "format:prettier": "prettier --write src/**/*.ts", "format": "run-s format:eslint format:prettier", - "lint": "eslint 'src/**/*.ts'", + "lint": "eslint src/**/*.ts", "test": "jest" }, "dependencies": { - "eventemitter3": "^4.0.4" + "eventemitter3": "^5.0.1" }, "publishConfig": { "access": "public" diff --git a/packages/textcomplete-core/src/Dropdown.ts b/packages/textcomplete-core/src/Dropdown.ts index b6714c2c..24c28c3d 100644 --- a/packages/textcomplete-core/src/Dropdown.ts +++ b/packages/textcomplete-core/src/Dropdown.ts @@ -248,8 +248,8 @@ export class Dropdown extends EventEmitter { return this.activeIndex < this.items.length - 1 ? this.activeIndex + 1 : this.option.rotate - ? 0 - : null + ? 0 + : null } private getPrevActiveIndex(): number | null { @@ -257,8 +257,8 @@ export class Dropdown extends EventEmitter { return this.activeIndex !== 0 ? this.activeIndex - 1 : this.option.rotate - ? this.items.length - 1 - : null + ? this.items.length - 1 + : null } private renderItems(): this { diff --git a/packages/textcomplete-core/src/Editor.ts b/packages/textcomplete-core/src/Editor.ts index a08fcb9e..67872957 100644 --- a/packages/textcomplete-core/src/Editor.ts +++ b/packages/textcomplete-core/src/Editor.ts @@ -109,20 +109,23 @@ export abstract class Editor extends EventEmitter { * @see {@link Textarea} for live example. */ protected getCode(e: KeyboardEvent): KeyCode { - return e.keyCode === 9 // tab - ? "ENTER" - : e.keyCode === 13 // enter - ? "ENTER" - : e.keyCode === 27 // esc - ? "ESC" - : e.keyCode === 38 // up - ? "UP" - : e.keyCode === 40 // down - ? "DOWN" - : e.keyCode === 78 && e.ctrlKey // ctrl-n - ? "DOWN" - : e.keyCode === 80 && e.ctrlKey // ctrl-p - ? "UP" - : "OTHER" + switch (e.keyCode) { + case 9: // tab + case 13: // enter + return "ENTER" + case 27: // esc + return "ESC" + case 38: // up + return "UP" + case 40: // down + return "DOWN" + case 78: // ctrl-n + if (e.ctrlKey) return "DOWN" + break + case 80: // ctrl-p + if (e.ctrlKey) return "UP" + break + } + return "OTHER" } } diff --git a/packages/textcomplete-textarea/README.md b/packages/textcomplete-textarea/README.md index 1f320392..d1a65abe 100644 --- a/packages/textcomplete-textarea/README.md +++ b/packages/textcomplete-textarea/README.md @@ -1,9 +1,11 @@ # @textcomplete/textarea -> Textcomplete editor for HTMLTextAreaElement. +Textcomplete editor for HTMLTextAreaElement. [![npm version](https://badge.fury.io/js/@textcomplete%2Ftextarea.svg)](http://badge.fury.io/js/@textcomplete%2Ftextarea) +Check the live demo [here](https://yuku.takahashi.coffee/textcomplete/#textcomplete-textarea). + ## Install ```bash diff --git a/packages/textcomplete-textarea/package.json b/packages/textcomplete-textarea/package.json index 1a90a797..813ecdc6 100644 --- a/packages/textcomplete-textarea/package.json +++ b/packages/textcomplete-textarea/package.json @@ -9,23 +9,23 @@ "author": "Yuku Takahashi", "license": "MIT", "scripts": { - "build": "rm -fr dist && tsc", - "format:eslint": "eslint --fix 'src/**/*.ts'", - "format:prettier": "prettier --write 'src/**/*.ts'", + "build": "rimraf dist && tsc", + "format:eslint": "eslint --fix src/**/*.ts", + "format:prettier": "prettier --write src/**/*.ts", "format": "run-s format:eslint format:prettier", - "lint": "eslint 'src/**/*.ts'" + "lint": "eslint src/**/*.ts" }, "dependencies": { - "@textcomplete/utils": "^0.1.11", + "@textcomplete/utils": "^0.1.12", "textarea-caret": "^3.1.0", "undate": "^0.3.0" }, "devDependencies": { - "@textcomplete/core": "^0.1.11", - "@types/textarea-caret": "^3.0.0" + "@textcomplete/core": "^0.1.12", + "@types/textarea-caret": "^3.0.3" }, "peerDependencies": { - "@textcomplete/core": "^0.1.9" + "@textcomplete/core": "^0.1.12" }, "publishConfig": { "access": "public" diff --git a/packages/textcomplete-utils/README.md b/packages/textcomplete-utils/README.md index 49f7bfde..5038b1be 100644 --- a/packages/textcomplete-utils/README.md +++ b/packages/textcomplete-utils/README.md @@ -1,9 +1,11 @@ # @textcomplete/utils -> Utility functions for Textcomplete editors. +Utility functions for Textcomplete editors. [![npm version](https://badge.fury.io/js/@textcomplete%2Futils.svg)](http://badge.fury.io/js/@textcomplete%2Futils) +Read more at [yuku.takahashi.coffee/textcomplete](https://yuku.takahashi.coffee/textcomplete/) + ## License © Yuku Takahashi - This software is licensed under the MIT license. diff --git a/packages/textcomplete-utils/package.json b/packages/textcomplete-utils/package.json index 3b0a6535..51e182cf 100644 --- a/packages/textcomplete-utils/package.json +++ b/packages/textcomplete-utils/package.json @@ -9,26 +9,16 @@ "author": "Yuku Takahashi", "license": "MIT", "scripts": { - "build": "rm -fr dist && tsc", - "format:eslint": "eslint --fix 'src/**/*.ts'", - "format:prettier": "prettier --write 'src/**/*.ts'", + "build": "rimraf dist && tsc", + "format:eslint": "eslint --fix src/**/*.ts", + "format:prettier": "prettier --write src/**/*.ts", "format": "run-s format:eslint format:prettier", - "lint": "eslint 'src/**/*.ts'" + "lint": "eslint src/**/*.ts" }, "devDependencies": { - "@textcomplete/core": "^0.1.11", - "@typescript-eslint/eslint-plugin": "^4.17.0", - "@typescript-eslint/parser": "^4.17.0", - "eslint": "^7.21.0", - "eslint-config-prettier": "^8.1.0", - "eslint-plugin-prettier": "^4.0.0", - "prettier": "^2.0.5", - "typescript": "^4.2.3" + "@textcomplete/core": "^0.1.12" }, "publishConfig": { "access": "public" - }, - "prettier": { - "semi": false } }