From 72864d1205c61893818938112419c4f057de028d Mon Sep 17 00:00:00 2001 From: Reversean Date: Thu, 2 Jul 2026 15:50:46 +0300 Subject: [PATCH] refactor(italic): extract italic inline tool into standalone package MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Move the built-in Italic inline tool out of @editorjs/core into its own publishable package, @editorjs/italic, mirroring the Paragraph and Bold extractions — the tool becomes independently versionable instead of bundled inside the editor core. No behavioral changes: the tool had no relative imports into core internals, so it moves as-is and core now depends on it as a workspace package. --- .github/workflows/italic.yml | 27 +++++++++++++++ README.md | 1 + packages/core/package.json | 1 + packages/core/src/index.ts | 3 +- packages/core/src/tools/internal/index.ts | 1 - packages/core/tsconfig.build.json | 3 ++ packages/core/tsconfig.json | 3 ++ packages/tools/italic/.gitignore | 24 +++++++++++++ packages/tools/italic/README.md | 3 ++ packages/tools/italic/eslint.config.mjs | 27 +++++++++++++++ packages/tools/italic/package.json | 29 ++++++++++++++++ .../italic => tools/italic/src}/index.ts | 0 packages/tools/italic/tsconfig.build.json | 13 +++++++ packages/tools/italic/tsconfig.eslint.json | 14 ++++++++ packages/tools/italic/tsconfig.json | 27 +++++++++++++++ yarn.lock | 34 ++++++++++--------- 16 files changed, 192 insertions(+), 18 deletions(-) create mode 100644 .github/workflows/italic.yml create mode 100644 packages/tools/italic/.gitignore create mode 100644 packages/tools/italic/README.md create mode 100644 packages/tools/italic/eslint.config.mjs create mode 100644 packages/tools/italic/package.json rename packages/{core/src/tools/internal/inline-tools/italic => tools/italic/src}/index.ts (100%) create mode 100644 packages/tools/italic/tsconfig.build.json create mode 100644 packages/tools/italic/tsconfig.eslint.json create mode 100644 packages/tools/italic/tsconfig.json diff --git a/.github/workflows/italic.yml b/.github/workflows/italic.yml new file mode 100644 index 00000000..a778a6b6 --- /dev/null +++ b/.github/workflows/italic.yml @@ -0,0 +1,27 @@ +name: Italic 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/italic' + + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v6 + - name: Build the package + uses: ./.github/actions/build + with: + package-name: '@editorjs/italic' diff --git a/README.md b/README.md index 6a65312b..4f221943 100644 --- a/README.md +++ b/README.md @@ -34,6 +34,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 | ## Documentation diff --git a/packages/core/package.json b/packages/core/package.json index 19cc5d32..1dd83192 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -45,6 +45,7 @@ "@editorjs/dom-adapters": "workspace:^", "@editorjs/editorjs": "^2.30.5", "@editorjs/helpers": "^1.2.2", + "@editorjs/italic": "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 5c72b5d6..6f3bad6a 100644 --- a/packages/core/src/index.ts +++ b/packages/core/src/index.ts @@ -21,7 +21,8 @@ import { EditorAPI } from './api/index.js'; import { generateId } from './utils/uid.js'; import { Paragraph } from '@editorjs/paragraph'; import { BoldInlineTool } from '@editorjs/bold'; -import { LinkInlineTool, ItalicInlineTool } from './tools/internal'; +import { ItalicInlineTool } from '@editorjs/italic'; +import { LinkInlineTool } from './tools/internal'; 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 index c27bb03c..a407976e 100644 --- a/packages/core/src/tools/internal/index.ts +++ b/packages/core/src/tools/internal/index.ts @@ -1,2 +1 @@ -export * from './inline-tools/italic/index.js'; export * from './inline-tools/link/index.js'; diff --git a/packages/core/tsconfig.build.json b/packages/core/tsconfig.build.json index 873030c3..120886cb 100644 --- a/packages/core/tsconfig.build.json +++ b/packages/core/tsconfig.build.json @@ -21,6 +21,9 @@ }, { "path": "../tools/bold/tsconfig.build.json" + }, + { + "path": "../tools/italic/tsconfig.build.json" } ] } diff --git a/packages/core/tsconfig.json b/packages/core/tsconfig.json index 202e4f1d..55d840a7 100644 --- a/packages/core/tsconfig.json +++ b/packages/core/tsconfig.json @@ -40,6 +40,9 @@ }, { "path": "../tools/bold/tsconfig.build.json" + }, + { + "path": "../tools/italic/tsconfig.build.json" } ] } diff --git a/packages/tools/italic/.gitignore b/packages/tools/italic/.gitignore new file mode 100644 index 00000000..854a697d --- /dev/null +++ b/packages/tools/italic/.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/italic/README.md b/packages/tools/italic/README.md new file mode 100644 index 00000000..809df416 --- /dev/null +++ b/packages/tools/italic/README.md @@ -0,0 +1,3 @@ +# Italic + +Built-in Editor.js Inline Tool for italic text formatting. diff --git a/packages/tools/italic/eslint.config.mjs b/packages/tools/italic/eslint.config.mjs new file mode 100644 index 00000000..d27b0622 --- /dev/null +++ b/packages/tools/italic/eslint.config.mjs @@ -0,0 +1,27 @@ +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', + 'n/no-unsupported-features/node-builtins': ['error', { + version: '>=24.0.0', + ignores: [], + }], + }, + }, +]; diff --git a/packages/tools/italic/package.json b/packages/tools/italic/package.json new file mode 100644 index 00000000..d6f8daa2 --- /dev/null +++ b/packages/tools/italic/package.json @@ -0,0 +1,29 @@ +{ + "name": "@editorjs/italic", + "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/italic/index.ts b/packages/tools/italic/src/index.ts similarity index 100% rename from packages/core/src/tools/internal/inline-tools/italic/index.ts rename to packages/tools/italic/src/index.ts diff --git a/packages/tools/italic/tsconfig.build.json b/packages/tools/italic/tsconfig.build.json new file mode 100644 index 00000000..5b7ae0fc --- /dev/null +++ b/packages/tools/italic/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/italic/tsconfig.eslint.json b/packages/tools/italic/tsconfig.eslint.json new file mode 100644 index 00000000..49c276af --- /dev/null +++ b/packages/tools/italic/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/italic/tsconfig.json b/packages/tools/italic/tsconfig.json new file mode 100644 index 00000000..8cc9fa49 --- /dev/null +++ b/packages/tools/italic/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 81a95561..f262d79d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2309,6 +2309,7 @@ __metadata: "@editorjs/dom-adapters": "workspace:^" "@editorjs/editorjs": "npm:^2.30.5" "@editorjs/helpers": "npm:^1.2.2" + "@editorjs/italic": "workspace:^" "@editorjs/model": "workspace:^" "@editorjs/paragraph": "workspace:^" "@editorjs/sdk": "workspace:^" @@ -2430,6 +2431,22 @@ __metadata: languageName: node linkType: hard +"@editorjs/italic@workspace:^, @editorjs/italic@workspace:packages/tools/italic": + version: 0.0.0-use.local + resolution: "@editorjs/italic@workspace:packages/tools/italic" + 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" @@ -12776,22 +12793,7 @@ __metadata: languageName: node linkType: hard -"yargs@npm:^17.3.1": - version: 17.7.3 - resolution: "yargs@npm:17.7.3" - dependencies: - cliui: "npm:^8.0.1" - escalade: "npm:^3.1.1" - get-caller-file: "npm:^2.0.5" - require-directory: "npm:^2.1.1" - string-width: "npm:^4.2.3" - y18n: "npm:^5.0.5" - yargs-parser: "npm:^21.1.1" - checksum: a3826798c03b159e139d0580a3b2733953889a9a1bac8e4e1ca7a1a249b55315b213c323a6a1dbdb305f6e59496a9eaa810742c87e34abcf1a0584d8f59212a1 - languageName: node - linkType: hard - -"yargs@npm:^17.7.2": +"yargs@npm:^17.3.1, yargs@npm:^17.7.2": version: 17.7.2 resolution: "yargs@npm:17.7.2" dependencies: