Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Align integration to work with self-service for premium features. #454

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"coverage": "ng test --watch=false --code-coverage",
"lint": "eslint \"*/**/*.+(js|mjs|ts)\"",
"changelog": "node ./scripts/changelog.mjs",
"build-package": "ng-packagr -p src/ckeditor/ng-package.json",
"build-package": "ng-packagr -p src/ckeditor/ng-package.json --config tsconfig.json",
"release:prepare-packages": "node scripts/preparepackages.mjs",
"release:publish-packages": "node scripts/publishpackages.mjs"
},
Expand All @@ -27,11 +27,11 @@
"@angular/platform-browser": "^16",
"@angular/platform-browser-dynamic": "^16",
"@angular/router": "^16",
"@ckeditor/ckeditor5-integrations-common": "^2.2.0",
"core-js": "^3.21.1",
"rxjs": "^6.5.5",
"tslib": "^2.0.3",
"zone.js": "~0.13.0",
"@ckeditor/ckeditor5-integrations-common": "^2.0.0"
"zone.js": "~0.13.0"
},
"devDependencies": {
"@angular-devkit/build-angular": "^16",
Expand Down
31 changes: 16 additions & 15 deletions scripts/preparepackages.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -69,22 +69,10 @@ const tasks = new Listr( [
}
},
{
title: 'Generating the `dist` directory.',
task: () => {
return devUtils.tools.shExec( 'yarn run build-package', { async: true, verbosity: 'silent' } );
}
},
{
title: 'Copying dist to release directory.',
task: () => {
return fs.copy( DIST_DIR, RELEASE_ANGULAR_DIR );
}
},
{
title: 'Updating the `#version` field in the `package.json` in the release directory',
title: 'Updating the `#version` field in the `package.json` in the source directory',
task: () => {
return devUtils.tools.updateJSONFile(
upath.join( RELEASE_ANGULAR_DIR, 'package.json' ),
upath.join( CKEDITOR5_ANGULAR_ROOT_DIR, 'src', 'ckeditor', 'package.json' ),
packageJson => {
packageJson.version = latestVersion;

Expand All @@ -100,6 +88,18 @@ const tasks = new Listr( [
return false;
}
},
{
title: 'Generating the `dist` directory.',
task: () => {
return devUtils.tools.shExec( 'yarn run build-package', { async: true, verbosity: 'silent' } );
}
},
{
title: 'Copying dist to release directory.',
task: () => {
return fs.copy( DIST_DIR, RELEASE_ANGULAR_DIR );
}
},
{
title: 'Copying required assets to the release directory.',
task: () => {
Expand All @@ -119,7 +119,8 @@ const tasks = new Listr( [
return releaseTools.commitAndTag( {
version: latestVersion,
files: [
'package.json'
'package.json',
'src/ckeditor/package.json'
]
} );
},
Expand Down
16 changes: 16 additions & 0 deletions src/ckeditor/ckeditor.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { TestBed, type ComponentFixture } from '@angular/core/testing';

import { AngularEditor } from 'src/editor/editor';
import { CKEditorComponent } from './ckeditor.component';
import { AngularIntegrationUsageDataPlugin } from './plugins/angular-integration-usage-data.plugin';

describe( 'CKEditorComponent', () => {
let component: CKEditorComponent;
Expand Down Expand Up @@ -128,6 +129,21 @@ describe( 'CKEditorComponent', () => {
} );
} );

describe( 'getConfig', () => {
it( 'should return config with AngularIntegrationUsageDataPlugin if non-free license passed', async () => {
( window as any ).CKEDITOR_VERSION = '44.0.0';
component.config.licenseKey = 'foo';

fixture.detectChanges();

await waitCycle();

const config = ( component as any ).getConfig();

expect( config.extraPlugins ).toContain( AngularIntegrationUsageDataPlugin );
} );
} );

describe( 'component data', () => {
it( 'initial data should be empty', async () => {
fixture.detectChanges();
Expand Down
3 changes: 2 additions & 1 deletion src/ckeditor/ckeditor.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import type {
import type { ControlValueAccessor } from '@angular/forms';

import { uid } from '@ckeditor/ckeditor5-integrations-common';
import { appendAllIntegrationPluginsToConfig } from './plugins/append-all-integration-plugins-to-config';

const ANGULAR_INTEGRATION_READ_ONLY_LOCK_ID = 'Lock from Angular integration (@ckeditor/ckeditor5-angular)';

Expand Down Expand Up @@ -453,7 +454,7 @@ export class CKEditorComponent<TEditor extends Editor = Editor> implements After
config.initialData = initialData;
}

return config;
return appendAllIntegrationPluginsToConfig( config );
}

/**
Expand Down
21 changes: 21 additions & 0 deletions src/ckeditor/plugins/angular-integration-usage-data.plugin.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/**
* @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md.
*/

import { VERSION } from '@angular/core';
import { createIntegrationUsageDataPlugin } from '@ckeditor/ckeditor5-integrations-common';
import pkg from '../package.json';

/**
* This part of the code is not executed in open-source implementations using a GPL key.
* It only runs when a specific license key is provided. If you are uncertain whether
* this applies to your installation, please contact our support team.
*/
export const AngularIntegrationUsageDataPlugin = createIntegrationUsageDataPlugin(
'angular',
{
version: pkg.version,
frameworkVersion: VERSION.full
}
);
30 changes: 30 additions & 0 deletions src/ckeditor/plugins/append-all-integration-plugins-to-config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/**
* @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md.
*/

import { appendExtraPluginsToEditorConfig, isCKEditorFreeLicense } from '@ckeditor/ckeditor5-integrations-common';
import type { EditorConfig, PluginConstructor } from 'ckeditor5';

import { AngularIntegrationUsageDataPlugin } from './angular-integration-usage-data.plugin';

/**
* Appends all integration plugins to the editor configuration.
*
* @param editorConfig The editor configuration.
* @returns The editor configuration with all integration plugins appended.
*/
export function appendAllIntegrationPluginsToConfig( editorConfig: EditorConfig ): EditorConfig {
const extraPlugins: Array<PluginConstructor> = [];

if ( !isCKEditorFreeLicense( editorConfig.licenseKey ) ) {
/**
* This part of the code is not executed in open-source implementations using a GPL key.
* It only runs when a specific license key is provided. If you are uncertain whether
* this applies to your installation, please contact our support team.
*/
extraPlugins.push( AngularIntegrationUsageDataPlugin );
}

return appendExtraPluginsToEditorConfig( editorConfig, extraPlugins );
}
2 changes: 2 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
"declaration": false,
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"resolveJsonModule": true,
"allowSyntheticDefaultImports": true,
"experimentalDecorators": true,
"skipLibCheck": true,
"target": "ES2022",
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2283,10 +2283,10 @@
"@ckeditor/ckeditor5-utils" "43.2.0"
ckeditor5 "43.2.0"

"@ckeditor/ckeditor5-integrations-common@^2.0.0":
version "2.1.0"
resolved "https://registry.yarnpkg.com/@ckeditor/ckeditor5-integrations-common/-/ckeditor5-integrations-common-2.1.0.tgz#5e1423ff764c421d8181a35f73677610038f1fb8"
integrity sha512-vn6qMb36sl6eSCc27dvThk6xISif59MxnxZmRBC440TyP7S9ZcS0ai4yHd5QyaH70ZIe0lhS7DWdLaiKtBggVQ==
"@ckeditor/ckeditor5-integrations-common@^2.2.0":
version "2.2.0"
resolved "https://registry.yarnpkg.com/@ckeditor/ckeditor5-integrations-common/-/ckeditor5-integrations-common-2.2.0.tgz#3eb75e21eddc880c87a675125ec3fcfe0c258847"
integrity sha512-qH68tqgyMibuejo+VAJ+iSH3ZmZweqBEzaawv9hZb4zzSMkBityWBjSc2hKXMtmJgCNsbSK84cyHpa5J/MNyLg==

"@ckeditor/ckeditor5-language@43.2.0":
version "43.2.0"
Expand Down