From 5cfdc1c0d5147016f5556a230b717798e8835c64 Mon Sep 17 00:00:00 2001 From: Reversean Date: Thu, 2 Jul 2026 16:00:24 +0300 Subject: [PATCH] refactor(link): extract link inline tool into standalone package MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Move the built-in Link inline tool out of @editorjs/core into its own publishable package, @editorjs/link, completing the split of all four built-in tools (paragraph, bold, italic, link) into independently versionable packages under packages/tools. This was the last tool living in core's internal tools folder, so the now-empty tools/internal directory is removed along with core's dependencies on @editorjs/dom and @codexteam/icons — both were only ever used by the tools that have now moved out. --- .github/workflows/link.yml | 27 ++++++++++++++++ README.md | 1 + packages/core/package.json | 3 +- packages/core/src/index.ts | 2 +- packages/core/src/tools/internal/index.ts | 1 - packages/core/tsconfig.build.json | 3 ++ packages/core/tsconfig.json | 3 ++ packages/tools/link/.gitignore | 24 ++++++++++++++ packages/tools/link/README.md | 3 ++ packages/tools/link/eslint.config.mjs | 32 +++++++++++++++++++ packages/tools/link/package.json | 29 +++++++++++++++++ .../link => tools/link/src}/index.ts | 0 packages/tools/link/tsconfig.build.json | 13 ++++++++ packages/tools/link/tsconfig.eslint.json | 14 ++++++++ packages/tools/link/tsconfig.json | 27 ++++++++++++++++ yarn.lock | 19 +++++++++-- 16 files changed, 195 insertions(+), 6 deletions(-) create mode 100644 .github/workflows/link.yml delete mode 100644 packages/core/src/tools/internal/index.ts create mode 100644 packages/tools/link/.gitignore create mode 100644 packages/tools/link/README.md create mode 100644 packages/tools/link/eslint.config.mjs create mode 100644 packages/tools/link/package.json rename packages/{core/src/tools/internal/inline-tools/link => tools/link/src}/index.ts (100%) create mode 100644 packages/tools/link/tsconfig.build.json create mode 100644 packages/tools/link/tsconfig.eslint.json create mode 100644 packages/tools/link/tsconfig.json diff --git a/.github/workflows/link.yml b/.github/workflows/link.yml new file mode 100644 index 00000000..af394d8a --- /dev/null +++ b/.github/workflows/link.yml @@ -0,0 +1,27 @@ +name: Link check +on: + pull_request: + merge_group: + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + +jobs: + lint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v6 + - name: Run ESLint check + uses: ./.github/actions/lint + with: + package-name: '@editorjs/link' + + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v6 + - name: Build the package + uses: ./.github/actions/build + with: + package-name: '@editorjs/link' diff --git a/README.md b/README.md index 4f221943..d85395cb 100644 --- a/README.md +++ b/README.md @@ -35,6 +35,7 @@ A model-driven, collaboration-ready Editor.js engine split into focused packages | [`@editorjs/paragraph`](packages/tools/paragraph) | Built-in Paragraph block tool | | [`@editorjs/bold`](packages/tools/bold) | Built-in Bold inline tool | | [`@editorjs/italic`](packages/tools/italic) | Built-in Italic inline tool | +| [`@editorjs/link`](packages/tools/link) | Built-in Link inline tool | ## Documentation diff --git a/packages/core/package.json b/packages/core/package.json index 1dd83192..fe404b61 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -38,14 +38,13 @@ "typescript": "^5.5.4" }, "dependencies": { - "@codexteam/icons": "^0.3.3", "@editorjs/bold": "workspace:^", "@editorjs/collaboration-manager": "workspace:^", - "@editorjs/dom": "^1.1.0", "@editorjs/dom-adapters": "workspace:^", "@editorjs/editorjs": "^2.30.5", "@editorjs/helpers": "^1.2.2", "@editorjs/italic": "workspace:^", + "@editorjs/link": "workspace:^", "@editorjs/model": "workspace:^", "@editorjs/paragraph": "workspace:^", "@editorjs/sdk": "workspace:^", diff --git a/packages/core/src/index.ts b/packages/core/src/index.ts index 6f3bad6a..862d1606 100644 --- a/packages/core/src/index.ts +++ b/packages/core/src/index.ts @@ -22,7 +22,7 @@ import { generateId } from './utils/uid.js'; import { Paragraph } from '@editorjs/paragraph'; import { BoldInlineTool } from '@editorjs/bold'; import { ItalicInlineTool } from '@editorjs/italic'; -import { LinkInlineTool } from './tools/internal'; +import { LinkInlineTool } from '@editorjs/link'; import { ShortcutsPlugin } from './plugins/ShortcutsPlugin.js'; import { DOMAdapters } from '@editorjs/dom-adapters'; import { BlocksManager } from './components/BlockManager.js'; diff --git a/packages/core/src/tools/internal/index.ts b/packages/core/src/tools/internal/index.ts deleted file mode 100644 index a407976e..00000000 --- a/packages/core/src/tools/internal/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './inline-tools/link/index.js'; diff --git a/packages/core/tsconfig.build.json b/packages/core/tsconfig.build.json index 120886cb..38f8418f 100644 --- a/packages/core/tsconfig.build.json +++ b/packages/core/tsconfig.build.json @@ -24,6 +24,9 @@ }, { "path": "../tools/italic/tsconfig.build.json" + }, + { + "path": "../tools/link/tsconfig.build.json" } ] } diff --git a/packages/core/tsconfig.json b/packages/core/tsconfig.json index 55d840a7..404fcf8c 100644 --- a/packages/core/tsconfig.json +++ b/packages/core/tsconfig.json @@ -43,6 +43,9 @@ }, { "path": "../tools/italic/tsconfig.build.json" + }, + { + "path": "../tools/link/tsconfig.build.json" } ] } diff --git a/packages/tools/link/.gitignore b/packages/tools/link/.gitignore new file mode 100644 index 00000000..854a697d --- /dev/null +++ b/packages/tools/link/.gitignore @@ -0,0 +1,24 @@ +.yarn/* +!.yarn/patches +!.yarn/plugins +!.yarn/releases +!.yarn/sdks +!.yarn/versions + +# Swap the comments on the following lines if you don't wish to use zero-installs +# Documentation here: https://yarnpkg.com/features/zero-installs +#!.yarn/cache +#.pnp.* + +# IDE +.idea/* + +node_modules/* +dist/* + +# tests +coverage/ +reports/ + +# stryker temp files +.stryker-tmp diff --git a/packages/tools/link/README.md b/packages/tools/link/README.md new file mode 100644 index 00000000..d5c19aef --- /dev/null +++ b/packages/tools/link/README.md @@ -0,0 +1,3 @@ +# Link + +Built-in Editor.js Inline Tool for linking selected text. diff --git a/packages/tools/link/eslint.config.mjs b/packages/tools/link/eslint.config.mjs new file mode 100644 index 00000000..e357a188 --- /dev/null +++ b/packages/tools/link/eslint.config.mjs @@ -0,0 +1,32 @@ +import CodeX from 'eslint-config-codex'; + +export default [ + ...CodeX, + { + languageOptions: { + parserOptions: { + project: './tsconfig.eslint.json', + tsconfigRootDir: import.meta.dirname, + sourceType: 'module', + }, + }, + rules: { + 'n/no-unpublished-import': ['error', { + allowModules: [ + 'eslint-config-codex', + ], + ignoreTypeImport: true, + }], + 'n/no-missing-import': 'off', + /** + * @todo remove when sdk's emitted declarations stop leaking the unresolvable `@/` path alias + * (see EditorAPI type reaching this package through InlineToolConstructorOptions) + */ + '@typescript-eslint/no-unsafe-assignment': 'off', + 'n/no-unsupported-features/node-builtins': ['error', { + version: '>=24.0.0', + ignores: [], + }], + }, + }, +]; diff --git a/packages/tools/link/package.json b/packages/tools/link/package.json new file mode 100644 index 00000000..48a40df7 --- /dev/null +++ b/packages/tools/link/package.json @@ -0,0 +1,29 @@ +{ + "name": "@editorjs/link", + "version": "0.0.0", + "packageManager": "yarn@4.0.1", + "main": "dist/index.js", + "types": "dist/index.d.ts", + "type": "module", + "scripts": { + "build": "yarn clear && tsc --build tsconfig.build.json", + "build:declaration": "yarn build --emitDeclarationOnly", + "lint": "eslint", + "lint:ci": "yarn lint --max-warnings 0", + "lint:fix": "yarn lint --fix", + "clear": "rm -rf dist && rm -f tsconfig.build.tsbuildinfo && rm -f tsconfig.tsbuildinfo" + }, + "devDependencies": { + "@types/eslint": "^9.6.1", + "@types/node": "^22.10.2", + "eslint": "^9.24.0", + "eslint-config-codex": "^2.0.3", + "eslint-plugin-import": "^2.31.0", + "typescript": "^5.5.4" + }, + "dependencies": { + "@codexteam/icons": "^0.3.3", + "@editorjs/dom": "^1.1.0", + "@editorjs/sdk": "workspace:^" + } +} diff --git a/packages/core/src/tools/internal/inline-tools/link/index.ts b/packages/tools/link/src/index.ts similarity index 100% rename from packages/core/src/tools/internal/inline-tools/link/index.ts rename to packages/tools/link/src/index.ts diff --git a/packages/tools/link/tsconfig.build.json b/packages/tools/link/tsconfig.build.json new file mode 100644 index 00000000..5b7ae0fc --- /dev/null +++ b/packages/tools/link/tsconfig.build.json @@ -0,0 +1,13 @@ +{ + "extends": "./tsconfig.json", + "exclude": [ + "node_modules/**/*", + "dist/**/*", + "**/*.spec.ts" + ], + "references": [ + { + "path": "../../sdk/tsconfig.build.json" + } + ] +} diff --git a/packages/tools/link/tsconfig.eslint.json b/packages/tools/link/tsconfig.eslint.json new file mode 100644 index 00000000..49c276af --- /dev/null +++ b/packages/tools/link/tsconfig.eslint.json @@ -0,0 +1,14 @@ +{ + "compilerOptions": { + "types": ["node"], + }, + "extends": "./tsconfig.json", + "include": [ + "src/**/*", + "eslint.config.mjs", + ], + "exclude": [ + "dist/**/*", + "node_modules/**/*", + ] +} diff --git a/packages/tools/link/tsconfig.json b/packages/tools/link/tsconfig.json new file mode 100644 index 00000000..8cc9fa49 --- /dev/null +++ b/packages/tools/link/tsconfig.json @@ -0,0 +1,27 @@ +{ + "compilerOptions": { + "composite": true, + "target": "esnext", + "module": "esnext", + "moduleResolution": "bundler", + "esModuleInterop": true, + "forceConsistentCasingInFileNames": true, + "strict": true, + "skipLibCheck": true, + "rootDir": "src", + "outDir": "dist", + "declaration": true, + "declarationMap": true, + "sourceMap": true + }, + "include": ["src/**/*"], + "exclude": [ + "node_modules/**/*", + "dist/**/*" + ], + "references": [ + { + "path": "../../sdk/tsconfig.build.json" + } + ] +} diff --git a/yarn.lock b/yarn.lock index f262d79d..6be014ac 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2302,14 +2302,13 @@ __metadata: dependencies: "@babel/core": "npm:^7.29.0" "@babel/preset-env": "npm:^7.29.2" - "@codexteam/icons": "npm:^0.3.3" "@editorjs/bold": "workspace:^" "@editorjs/collaboration-manager": "workspace:^" - "@editorjs/dom": "npm:^1.1.0" "@editorjs/dom-adapters": "workspace:^" "@editorjs/editorjs": "npm:^2.30.5" "@editorjs/helpers": "npm:^1.2.2" "@editorjs/italic": "workspace:^" + "@editorjs/link": "workspace:^" "@editorjs/model": "workspace:^" "@editorjs/paragraph": "workspace:^" "@editorjs/sdk": "workspace:^" @@ -2447,6 +2446,22 @@ __metadata: languageName: unknown linkType: soft +"@editorjs/link@workspace:^, @editorjs/link@workspace:packages/tools/link": + version: 0.0.0-use.local + resolution: "@editorjs/link@workspace:packages/tools/link" + dependencies: + "@codexteam/icons": "npm:^0.3.3" + "@editorjs/dom": "npm:^1.1.0" + "@editorjs/sdk": "workspace:^" + "@types/eslint": "npm:^9.6.1" + "@types/node": "npm:^22.10.2" + eslint: "npm:^9.24.0" + eslint-config-codex: "npm:^2.0.3" + eslint-plugin-import: "npm:^2.31.0" + typescript: "npm:^5.5.4" + languageName: unknown + linkType: soft + "@editorjs/model-types@workspace:^, @editorjs/model-types@workspace:packages/model-types": version: 0.0.0-use.local resolution: "@editorjs/model-types@workspace:packages/model-types"