-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #32 from ckeditor/ck/improve-errors
Feature: Improved error readability in `loadCKEditorCloud`. It should now detect existing editor instances and provide migration info from NPM to CDN.
- Loading branch information
Showing
25 changed files
with
498 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
/** | ||
* @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved. | ||
* For licensing, see LICENSE.md. | ||
*/ | ||
|
||
import type { SemanticVersion } from '@/utils/isSemanticVersion'; | ||
|
||
export const CK_DOCS_URL = 'https://ckeditor.com/docs/ckeditor5'; | ||
|
||
/** | ||
* Creates a URL to a file on the CKEditor documentation. | ||
*/ | ||
export function createCKDocsUrl( path: string, version: SemanticVersion | 'latest' = 'latest' ): string { | ||
return `${ CK_DOCS_URL }/${ version }/${ path }`; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/** | ||
* @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved. | ||
* For licensing, see LICENSE.md. | ||
*/ | ||
|
||
import type { BundleInstallationInfo } from './types'; | ||
|
||
import { isSemanticVersion } from '@/utils/isSemanticVersion'; | ||
|
||
/** | ||
* Returns information about the base CKEditor bundle installation. | ||
*/ | ||
export function getCKBaseBundleInstallationInfo(): BundleInstallationInfo | null { | ||
const { CKEDITOR_VERSION, CKEDITOR } = window; | ||
|
||
if ( !isSemanticVersion( CKEDITOR_VERSION ) ) { | ||
return null; | ||
} | ||
|
||
// Global `CKEDITOR` is set only in CDN builds. | ||
return { | ||
source: CKEDITOR ? 'cdn' : 'npm', | ||
version: CKEDITOR_VERSION | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/** | ||
* @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved. | ||
* For licensing, see LICENSE.md. | ||
*/ | ||
|
||
import type { BundleInstallationInfo } from './types'; | ||
|
||
import { isSemanticVersion } from '@/utils/isSemanticVersion'; | ||
|
||
/** | ||
* Returns information about the CKBox installation. | ||
*/ | ||
export function getCKBoxInstallationInfo(): BundleInstallationInfo | null { | ||
const version = window.CKBox?.version; | ||
|
||
if ( !isSemanticVersion( version ) ) { | ||
return null; | ||
} | ||
|
||
return { | ||
source: 'cdn', | ||
version | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/** | ||
* @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved. | ||
* For licensing, see LICENSE.md. | ||
*/ | ||
|
||
import type { SemanticVersion } from '@/utils/isSemanticVersion'; | ||
|
||
/** | ||
* The source from which CKEditor was installed. | ||
*/ | ||
type BundleInstallationSource = 'npm' | 'cdn'; | ||
|
||
/** | ||
* Information about the currently installed CKEditor. | ||
*/ | ||
export type BundleInstallationInfo = { | ||
|
||
/** | ||
* The source from which CKEditor was installed. | ||
*/ | ||
source: BundleInstallationSource; | ||
|
||
/** | ||
* The version of CKEditor. | ||
*/ | ||
version: SemanticVersion; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/** | ||
* @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved. | ||
* For licensing, see LICENSE.md. | ||
*/ | ||
|
||
export type SemanticVersion = `${ number }.${ number }.${ number }`; | ||
|
||
/** | ||
* Checks if the given string is a semantic version number. | ||
* | ||
* @param version - The string to check. | ||
* @returns `true` if the string is a semantic version, `false` otherwise. | ||
*/ | ||
export function isSemanticVersion( version: string | undefined | null ): version is SemanticVersion { | ||
return !!version && /^\d+\.\d+\.\d+/.test( version ); | ||
} |
Oops, something went wrong.