From bffe09a82328c8e5b41a33cab0616463cabb941c Mon Sep 17 00:00:00 2001 From: Marcin Panek Date: Wed, 19 Apr 2023 12:37:21 +0200 Subject: [PATCH 1/4] Add `augmentation.ts` to the TypeScript package generator. --- .../lib/templates/ts/sample/index.html | 1 + .../lib/templates/ts/src/_PLACEHOLDER_.ts.txt | 1 + .../lib/templates/ts/src/augmentation.ts.txt | 7 +++++++ .../lib/templates/ts/tsconfig.json.txt | 3 ++- 4 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 packages/ckeditor5-package-generator/lib/templates/ts/src/augmentation.ts.txt diff --git a/packages/ckeditor5-package-generator/lib/templates/ts/sample/index.html b/packages/ckeditor5-package-generator/lib/templates/ts/sample/index.html index 1b793cea..65539937 100644 --- a/packages/ckeditor5-package-generator/lib/templates/ts/sample/index.html +++ b/packages/ckeditor5-package-generator/lib/templates/ts/sample/index.html @@ -72,6 +72,7 @@

The directory structure

│ └─ ckeditor.ts # The editor initialization script. ├─ src │ ├─ <%= formattedNames.plugin.lowerCaseMerged %>.ts +│ ├─ augmentation.ts # Type augmentations for the `@ckeditor/ckeditor5-core` module. Read more in PlugginsMap and CommandsMap. │ ├─ index.ts # The modules exported by the package when using the DLL builds. │ └─ **/*.ts # All TypeScript source files should be saved here. ├─ tests diff --git a/packages/ckeditor5-package-generator/lib/templates/ts/src/_PLACEHOLDER_.ts.txt b/packages/ckeditor5-package-generator/lib/templates/ts/src/_PLACEHOLDER_.ts.txt index 97374dac..f5128786 100644 --- a/packages/ckeditor5-package-generator/lib/templates/ts/src/_PLACEHOLDER_.ts.txt +++ b/packages/ckeditor5-package-generator/lib/templates/ts/src/_PLACEHOLDER_.ts.txt @@ -1,5 +1,6 @@ import { Plugin } from 'ckeditor5/src/core'; import { ButtonView } from 'ckeditor5/src/ui'; +import './augmentation'; import ckeditor5Icon from '../theme/icons/ckeditor.svg'; diff --git a/packages/ckeditor5-package-generator/lib/templates/ts/src/augmentation.ts.txt b/packages/ckeditor5-package-generator/lib/templates/ts/src/augmentation.ts.txt new file mode 100644 index 00000000..e51fa103 --- /dev/null +++ b/packages/ckeditor5-package-generator/lib/templates/ts/src/augmentation.ts.txt @@ -0,0 +1,7 @@ +import type { <%= formattedNames.plugin.pascalCase %> } from './index'; + +declare module '@ckeditor/ckeditor5-core' { + interface PluginsMap { + [ <%= formattedNames.plugin.pascalCase %>.pluginName ]: <%= formattedNames.plugin.pascalCase %>; + } +} diff --git a/packages/ckeditor5-package-generator/lib/templates/ts/tsconfig.json.txt b/packages/ckeditor5-package-generator/lib/templates/ts/tsconfig.json.txt index 20be4716..11999f7f 100644 --- a/packages/ckeditor5-package-generator/lib/templates/ts/tsconfig.json.txt +++ b/packages/ckeditor5-package-generator/lib/templates/ts/tsconfig.json.txt @@ -1,7 +1,8 @@ { "compilerOptions": { "lib": [ - "DOM" + "DOM", + "DOM.Iterable" ], "noImplicitAny": true, "noImplicitOverride": true, From 96c9ed2369715a65c6f117a8f1b0673fade34770 Mon Sep 17 00:00:00 2001 From: Marcin Panek Date: Wed, 19 Apr 2023 13:10:18 +0200 Subject: [PATCH 2/4] Fix travis build. --- scripts/ci/travis-check.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/scripts/ci/travis-check.js b/scripts/ci/travis-check.js index 9780555d..a7c4ca74 100644 --- a/scripts/ci/travis-check.js +++ b/scripts/ci/travis-check.js @@ -33,8 +33,10 @@ const EXPECTED_PUBLISH_FILES = { 'ckeditor5-metadata.json' ], ts: [ + 'src/augmentation.js', 'src/index.js', 'src/testpackage.js', + 'src/augmentation.d.ts', 'src/index.d.ts', 'src/testpackage.d.ts', @@ -55,6 +57,7 @@ const EXPECTED_SRC_DIR_FILES = { 'testpackage.js' ], ts: [ + 'augmentation.ts', 'index.ts', 'testpackage.ts' ] From feaae81a9cee0eefe62dea4c2ec52cfbf488cfd7 Mon Sep 17 00:00:00 2001 From: Marcin Panek Date: Wed, 19 Apr 2023 15:36:56 +0200 Subject: [PATCH 3/4] Move `augmentation.ts` import to `index.ts`. --- .../lib/templates/ts/src/_PLACEHOLDER_.ts.txt | 1 - .../lib/templates/ts/src/index.ts.txt | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/ckeditor5-package-generator/lib/templates/ts/src/_PLACEHOLDER_.ts.txt b/packages/ckeditor5-package-generator/lib/templates/ts/src/_PLACEHOLDER_.ts.txt index f5128786..97374dac 100644 --- a/packages/ckeditor5-package-generator/lib/templates/ts/src/_PLACEHOLDER_.ts.txt +++ b/packages/ckeditor5-package-generator/lib/templates/ts/src/_PLACEHOLDER_.ts.txt @@ -1,6 +1,5 @@ import { Plugin } from 'ckeditor5/src/core'; import { ButtonView } from 'ckeditor5/src/ui'; -import './augmentation'; import ckeditor5Icon from '../theme/icons/ckeditor.svg'; diff --git a/packages/ckeditor5-package-generator/lib/templates/ts/src/index.ts.txt b/packages/ckeditor5-package-generator/lib/templates/ts/src/index.ts.txt index 1ee904a1..98015ca6 100644 --- a/packages/ckeditor5-package-generator/lib/templates/ts/src/index.ts.txt +++ b/packages/ckeditor5-package-generator/lib/templates/ts/src/index.ts.txt @@ -1,4 +1,5 @@ import ckeditor from './../theme/icons/ckeditor.svg'; +import './augmentation'; export { default as <%= formattedNames.plugin.pascalCase %> } from './<%= formattedNames.plugin.lowerCaseMerged %>'; From 1e00b934f2fcf6b7ca76dc94683b1f906d14363e Mon Sep 17 00:00:00 2001 From: Kamil Piechaczek Date: Thu, 20 Apr 2023 10:49:54 +0200 Subject: [PATCH 4/4] Wording.. --- .../lib/templates/ts/sample/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/ckeditor5-package-generator/lib/templates/ts/sample/index.html b/packages/ckeditor5-package-generator/lib/templates/ts/sample/index.html index 65539937..12f3a4f9 100644 --- a/packages/ckeditor5-package-generator/lib/templates/ts/sample/index.html +++ b/packages/ckeditor5-package-generator/lib/templates/ts/sample/index.html @@ -72,7 +72,7 @@

The directory structure

│ └─ ckeditor.ts # The editor initialization script. ├─ src │ ├─ <%= formattedNames.plugin.lowerCaseMerged %>.ts -│ ├─ augmentation.ts # Type augmentations for the `@ckeditor/ckeditor5-core` module. Read more in PlugginsMap and CommandsMap. +│ ├─ augmentation.ts # Type augmentations for the `@ckeditor/ckeditor5-core` module. Read more in PluginsMap and CommandsMap. │ ├─ index.ts # The modules exported by the package when using the DLL builds. │ └─ **/*.ts # All TypeScript source files should be saved here. ├─ tests