@ckeditor/ckeditor5-utils
Advanced tools
Comparing version 13.0.1 to 14.0.0
Changelog | ||
========= | ||
## [14.0.0](https://github.com/ckeditor/ckeditor5-utils/compare/v13.0.1...v14.0.0) (2019-08-26) | ||
### Features | ||
* Add feature detection of Unicode properties entities' support. ([21c0f6b](https://github.com/ckeditor/ckeditor5-utils/commit/21c0f6b)) | ||
* Allowed specifying editor content language in `Locale`. Implemented the (UI and content) language direction discovery in `Locale`. Implemented `Locale#uiLanguage`, `Locale#uiLanguageDirection`, `Locale#contentLanguage`, and `Locale#contentLanguageDirection` properties. See [ckeditor/ckeditor5#1151](https://github.com/ckeditor/ckeditor5/issues/1151). ([91c95f3](https://github.com/ckeditor/ckeditor5-utils/commit/91c95f3)) | ||
### Other changes | ||
* The issue tracker for this package was moved to https://github.com/ckeditor/ckeditor5/issues. See [ckeditor/ckeditor5#1988](https://github.com/ckeditor/ckeditor5/issues/1988). ([71469ac](https://github.com/ckeditor/ckeditor5-utils/commit/71469ac)) | ||
* Removed the CKEditor 5 logger and its usage. Part of [ckeditor/ckeditor5#383](https://github.com/ckeditor/ckeditor5/issues/383). ([584ef1d](https://github.com/ckeditor/ckeditor5-utils/commit/584ef1d)) | ||
### BREAKING CHANGES | ||
* The`Locale()` constructor arguments syntax has changed. Please refer to the API documentation to learn more. | ||
* The `Locale#language` property has been deprecated by `Locale#uiLanguage`. Please refer to the API documentation to learn more. | ||
* Removed the CKEditor 5 logger utility. | ||
## [13.0.1](https://github.com/ckeditor/ckeditor5-utils/compare/v13.0.0...v13.0.1) (2019-07-10) | ||
@@ -5,0 +24,0 @@ |
{ | ||
"name": "@ckeditor/ckeditor5-utils", | ||
"version": "13.0.1", | ||
"version": "14.0.0", | ||
"description": "Miscellaneous utils used by CKEditor 5.", | ||
@@ -12,9 +12,10 @@ "keywords": [ | ||
"dependencies": { | ||
"ckeditor5": "^12.3.1", | ||
"ckeditor5": "^12.4.0", | ||
"lodash-es": "^4.17.10" | ||
}, | ||
"devDependencies": { | ||
"@ckeditor/ckeditor5-build-classic": "^12.3.1", | ||
"@ckeditor/ckeditor5-core": "^12.2.1", | ||
"@ckeditor/ckeditor5-engine": "^13.2.1", | ||
"@ckeditor/ckeditor5-build-classic": "^12.4.0", | ||
"@ckeditor/ckeditor5-editor-classic": "^12.1.4", | ||
"@ckeditor/ckeditor5-core": "^12.3.0", | ||
"@ckeditor/ckeditor5-engine": "^14.0.0", | ||
"eslint": "^5.5.0", | ||
@@ -32,3 +33,3 @@ "eslint-config-ckeditor5": "^2.0.0", | ||
"homepage": "https://ckeditor.com/ckeditor-5", | ||
"bugs": "https://github.com/ckeditor/ckeditor5-utils/issues", | ||
"bugs": "https://github.com/ckeditor/ckeditor5/issues", | ||
"repository": { | ||
@@ -35,0 +36,0 @@ "type": "git", |
@@ -19,7 +19,24 @@ /** | ||
* | ||
* All errors will be shortened during the minification process in order to reduce the code size. | ||
* Therefore, all error messages should be documented in the same way as those in {@link module:utils/log}. | ||
* You should throw `CKEditorError` when: | ||
* | ||
* Read more in the {@link module:utils/log} module. | ||
* * An unexpected situation occurred and the editor (most probably) will not work properly. Such exception will be handled | ||
* by the {@link module:watchdog/watchdog~Watchdog watchdog} (if it is integrated), | ||
* * If the editor is incorrectly integrated or the editor API is used in the wrong way. This way you will give | ||
* feedback to the developer as soon as possible. Keep in mind that for common integration issues which should not | ||
* stop editor initialization (like missing upload adapter, wrong name of a toolbar component) we use `console.warn()` with | ||
* {@link module:utils/ckeditorerror~attachLinkToDocumentation `attachLinkToDocumentation()`} | ||
* to improve developers experience and let them see the working editor as soon as possible. | ||
* | ||
* /** | ||
* * Error thrown when a plugin cannot be loaded due to JavaScript errors, lack of plugins with a given name, etc. | ||
* * | ||
* * @error plugin-load | ||
* * @param pluginName The name of the plugin that could not be loaded. | ||
* * @param moduleName The name of the module which tried to load this plugin. | ||
* * / | ||
* throw new CKEditorError( 'plugin-load: It was not possible to load the "{$pluginName}" plugin in module "{$moduleName}', { | ||
* pluginName: 'foo', | ||
* moduleName: 'bar' | ||
* } ); | ||
* | ||
* @extends Error | ||
@@ -31,4 +48,2 @@ */ | ||
* | ||
* Read more about error logging in the {@link module:utils/log} module. | ||
* | ||
* @param {String} message The error message in an `error-name: Error message.` format. | ||
@@ -84,4 +99,15 @@ * During the minification process the "Error message" part will be removed to limit the code size | ||
/** | ||
* Attaches link to the documentation at the end of the error message. | ||
* Attaches the link to the documentation at the end of the error message. Use whenever you log a warning or error on the | ||
* console. It is also used by {@link module:utils/ckeditorerror~CKEditorError}. | ||
* | ||
* /** | ||
* * There was a problem processing the configuration of the toolbar. The item with the given | ||
* * name does not exist so it was omitted when rendering the toolbar. | ||
* * | ||
* * @error toolbarview-item-unavailable | ||
* * @param {String} name The name of the component. | ||
* * / | ||
* console.warn( attachLinkToDocumentation( | ||
* 'toolbarview-item-unavailable: The requested toolbar item is unavailable.' ), { name } ); | ||
* | ||
* @param {String} message Message to be logged. | ||
@@ -88,0 +114,0 @@ * @returns {String} |
@@ -13,3 +13,2 @@ /** | ||
import getBorderWidths from './getborderwidths'; | ||
import log from '../log'; | ||
import isText from './istext'; | ||
@@ -71,23 +70,13 @@ import { isElement } from 'lodash-es'; | ||
if ( isElement( source ) || isSourceRange ) { | ||
const sourceNode = isSourceRange ? source.startContainer : source; | ||
// The `Rect` class depends on `getBoundingClientRect` and `getClientRects` DOM methods. If the source | ||
// of a rect in an HTML element or a DOM range but it does not belong to any rendered DOM tree, these methods | ||
// will fail to obtain the geometry and the rect instance makes little sense to the features using it. | ||
// To get rid of this warning make sure the source passed to the constructor is a descendant of `window.document.body`. | ||
// @if CK_DEBUG // const sourceNode = isSourceRange ? source.startContainer : source; | ||
// @if CK_DEBUG // if ( !sourceNode.ownerDocument || !sourceNode.ownerDocument.body.contains( sourceNode ) ) { | ||
// @if CK_DEBUG // console.warn( | ||
// @if CK_DEBUG // 'rect-source-not-in-dom: The source of this rect does not belong to any rendered DOM tree.', | ||
// @if CK_DEBUG // { source } ); | ||
// @if CK_DEBUG // } | ||
if ( !sourceNode.ownerDocument || !sourceNode.ownerDocument.body.contains( sourceNode ) ) { | ||
/** | ||
* The `Rect` class depends on `getBoundingClientRect` and `getClientRects` DOM methods. | ||
* If the {@link #constructor source} of a rect in an HTML element or a DOM range but it does | ||
* not belong to any rendered DOM tree, these methods will fail to obtain the geometry and | ||
* the rect instance makes little sense to the features using it. | ||
* | ||
* To get rid of this warning make sure the source passed to the constructor | ||
* is a descendant of `window.document.body`. | ||
* | ||
* @error rect-source-not-in-dom | ||
* @param {String} source The source of the Rect instance. | ||
*/ | ||
log.warn( | ||
'rect-source-not-in-dom: The source of this rect does not belong to any rendered DOM tree.', | ||
{ source } | ||
); | ||
} | ||
if ( isSourceRange ) { | ||
@@ -94,0 +83,0 @@ copyRectProperties( this, Rect.getDomRangeRects( source )[ 0 ] ); |
@@ -432,5 +432,5 @@ /** | ||
* @protected | ||
* @param {module:utils/emittermixin~EmitterMixin} listeningEmitter Emitter that listens. | ||
* @param {module:utils/emittermixin~Emitter} listeningEmitter An emitter that listens. | ||
* @param {String} listenedToEmitterId Unique emitter id of emitter listened to. | ||
* @returns {module:utils/emittermixin~EmitterMixin|null} | ||
* @returns {module:utils/emittermixin~Emitter|null} | ||
*/ | ||
@@ -451,3 +451,3 @@ export function _getEmitterListenedTo( listeningEmitter, listenedToEmitterId ) { | ||
* @protected | ||
* @param {module:utils/emittermixin~EmitterMixin} emitter Emitter for which id will be set. | ||
* @param {module:utils/emittermixin~Emitter} emitter An emitter for which id will be set. | ||
* @param {String} [id] Unique id to set. If not passed, random unique id will be set. | ||
@@ -465,3 +465,3 @@ */ | ||
* @protected | ||
* @param {module:utils/emittermixin~EmitterMixin} emitter Emitter which id will be returned. | ||
* @param {module:utils/emittermixin~Emitter} emitter An emitter which id will be returned. | ||
*/ | ||
@@ -468,0 +468,0 @@ export function _getEmitterId( emitter ) { |
@@ -58,3 +58,20 @@ /** | ||
*/ | ||
isAndroid: isAndroid( userAgent ) | ||
isAndroid: isAndroid( userAgent ), | ||
/** | ||
* Environment features information. | ||
* | ||
* @memberOf module:utils/env~env | ||
* @namespace | ||
*/ | ||
features: { | ||
/** | ||
* Indicates that the environment supports ES2018 Unicode property escapes — like `\p{P}` or `\p{L}`. | ||
* More information about unicode properties might be found | ||
* [in Unicode Standard Annex #44](https://www.unicode.org/reports/tr44/#GC_Values_Table). | ||
* | ||
* @type {Boolean} | ||
*/ | ||
isRegExpUnicodePropertySupported: isRegExpUnicodePropertySupported() | ||
} | ||
}; | ||
@@ -113,1 +130,24 @@ | ||
} | ||
/** | ||
* Checks if the current environment supports ES2018 Unicode properties like `\p{P}` or `\p{L}`. | ||
* More information about unicode properties might be found | ||
* [in Unicode Standard Annex #44](https://www.unicode.org/reports/tr44/#GC_Values_Table). | ||
* | ||
* @returns {Boolean} | ||
*/ | ||
export function isRegExpUnicodePropertySupported() { | ||
let isSupported = false; | ||
// Feature detection for Unicode properties. Added in ES2018. Currently Firefox and Edge do not support it. | ||
// See https://github.com/ckeditor/ckeditor5-mention/issues/44#issuecomment-487002174. | ||
try { | ||
// Usage of regular expression literal cause error during build (ckeditor/ckeditor5-dev#534). | ||
isSupported = 'ć'.search( new RegExp( '[\\p{L}]', 'u' ) ) === 0; | ||
} catch ( error ) { | ||
// Firefox throws a SyntaxError when the group is unsupported. | ||
} | ||
return isSupported; | ||
} |
@@ -10,4 +10,8 @@ /** | ||
/* globals console */ | ||
import { translate } from './translation-service'; | ||
const RTL_LANGUAGE_CODES = [ 'ar', 'fa', 'he', 'ku', 'ug' ]; | ||
/** | ||
@@ -18,19 +22,63 @@ * Represents the localization services. | ||
/** | ||
* Creates a new instance of the Locale class. | ||
* Creates a new instance of the Locale class. Learn more about | ||
* {@glink features/ui-language configuring language of the editor}. | ||
* | ||
* @param {String} [language='en'] The language code in [ISO 639-1](https://en.wikipedia.org/wiki/ISO_639-1) format. | ||
* @param {Object} [options] Locale configuration. | ||
* @param {String} [options.uiLanguage='en'] The editor UI language code in the | ||
* [ISO 639-1](https://en.wikipedia.org/wiki/ISO_639-1) format. See {@link #uiLanguage}. | ||
* @param {String} [options.contentLanguage] The editor content language code in the | ||
* [ISO 639-1](https://en.wikipedia.org/wiki/ISO_639-1) format. If not specified, the same as `options.language`. | ||
* See {@link #contentLanguage}. | ||
*/ | ||
constructor( language ) { | ||
constructor( options = {} ) { | ||
/** | ||
* The language code in [ISO 639-1](https://en.wikipedia.org/wiki/ISO_639-1) format. | ||
* The editor UI language code in the [ISO 639-1](https://en.wikipedia.org/wiki/ISO_639-1) format. | ||
* | ||
* If the {@link #contentLanguage content language} was not specified in the `Locale` constructor, | ||
* it also defines the language of the content. | ||
* | ||
* @readonly | ||
* @member {String} | ||
*/ | ||
this.language = language || 'en'; | ||
this.uiLanguage = options.uiLanguage || 'en'; | ||
/** | ||
* Translates the given string to the {@link #language}. This method is also available in {@link module:core/editor/editor~Editor#t} | ||
* and {@link module:ui/view~View#t}. | ||
* The editor content language code in the [ISO 639-1](https://en.wikipedia.org/wiki/ISO_639-1) format. | ||
* | ||
* Usually the same as {@link #uiLanguage editor language}, it can be customized by passing an optional | ||
* argument to the `Locale` constructor. | ||
* | ||
* @readonly | ||
* @member {String} | ||
*/ | ||
this.contentLanguage = options.contentLanguage || this.uiLanguage; | ||
/** | ||
* Text direction of the {@link #uiLanguage editor UI language}. Either `'ltr'` or `'rtl'`. | ||
* | ||
* @readonly | ||
* @member {String} | ||
*/ | ||
this.uiLanguageDirection = getLanguageDirection( this.uiLanguage ); | ||
/** | ||
* Text direction of the {@link #contentLanguage editor content language}. | ||
* | ||
* If the content language was passed directly to the `Locale` constructor, this property represents the | ||
* direction of that language. | ||
* | ||
* If the {@link #contentLanguage editor content language} was derived from the {@link #uiLanguage editor language}, | ||
* the content language direction is the same as the {@link #uiLanguageDirection UI language direction}. | ||
* | ||
* The value is either `'ltr'` or `'rtl'`. | ||
* | ||
* @readonly | ||
* @member {String} | ||
*/ | ||
this.contentLanguageDirection = getLanguageDirection( this.contentLanguage ); | ||
/** | ||
* Translates the given string to the {@link #uiLanguage}. This method is also available in | ||
* {@link module:core/editor/editor~Editor#t} and {@link module:ui/view~View#t}. | ||
* | ||
* The strings may contain placeholders (`%<index>`) for values which are passed as the second argument. | ||
@@ -55,2 +103,26 @@ * `<index>` is the index in the `values` array. | ||
/** | ||
* The editor UI language code in the [ISO 639-1](https://en.wikipedia.org/wiki/ISO_639-1) format. | ||
* | ||
* **Note**: This property has been deprecated. Please use {@link #uiLanguage} and {@link #contentLanguage} | ||
* properties instead. | ||
* | ||
* @deprecated | ||
* @member {String} | ||
*/ | ||
get language() { | ||
/** | ||
* The {@link module:utils/locale~Locale#language `Locale#language`} property has been deprecated and will | ||
* be removed in the near future. Please use {@link #uiLanguage} and {@link #contentLanguage} properties instead. | ||
* | ||
* @error locale-deprecated-language-property | ||
*/ | ||
console.warn( | ||
'locale-deprecated-language-property: ' + | ||
'The Locale#language property has been deprecated and will be removed in the near future. ' + | ||
'Please use #uiLanguage and #contentLanguage properties instead.' ); | ||
return this.uiLanguage; | ||
} | ||
/** | ||
* Base for the {@link #t} method. | ||
@@ -61,3 +133,3 @@ * | ||
_t( str, values ) { | ||
let translatedString = translate( this.language, str ); | ||
let translatedString = translate( this.uiLanguage, str ); | ||
@@ -73,1 +145,9 @@ if ( values ) { | ||
} | ||
// Helps determine whether a language is LTR or RTL. | ||
// | ||
// @param {String} language The ISO 639-1 language code. | ||
// @returns {String} 'ltr' or 'rtl | ||
function getLanguageDirection( languageCode ) { | ||
return RTL_LANGUAGE_CODES.includes( languageCode ) ? 'rtl' : 'ltr'; | ||
} |
@@ -12,4 +12,4 @@ /** | ||
import log from './log'; | ||
import { version } from 'ckeditor5/package.json'; | ||
import CKEditorError from './ckeditorerror'; | ||
@@ -142,5 +142,8 @@ const windowOrGlobal = typeof window === 'object' ? window : global; | ||
*/ | ||
log.error( 'ckeditor-duplicated-modules: Some CKEditor 5 modules are duplicated.' ); | ||
throw new CKEditorError( | ||
'ckeditor-duplicated-modules: Some CKEditor 5 modules are duplicated.', | ||
null | ||
); | ||
} else { | ||
windowOrGlobal.CKEDITOR_VERSION = version; | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
224792
5656
8
55
Updatedckeditor5@^12.4.0