@ckeditor/ckeditor5-link
Advanced tools
Comparing version 23.0.0 to 23.1.0
{ | ||
"name": "@ckeditor/ckeditor5-link", | ||
"version": "23.0.0", | ||
"version": "23.1.0", | ||
"description": "Link feature for CKEditor 5.", | ||
@@ -13,20 +13,20 @@ "keywords": [ | ||
"dependencies": { | ||
"@ckeditor/ckeditor5-clipboard": "^23.0.0", | ||
"@ckeditor/ckeditor5-core": "^23.0.0", | ||
"@ckeditor/ckeditor5-engine": "^23.0.0", | ||
"@ckeditor/ckeditor5-image": "^23.0.0", | ||
"@ckeditor/ckeditor5-typing": "^23.0.0", | ||
"@ckeditor/ckeditor5-ui": "^23.0.0", | ||
"@ckeditor/ckeditor5-utils": "^23.0.0", | ||
"@ckeditor/ckeditor5-clipboard": "^23.1.0", | ||
"@ckeditor/ckeditor5-core": "^23.1.0", | ||
"@ckeditor/ckeditor5-engine": "^23.1.0", | ||
"@ckeditor/ckeditor5-image": "^23.1.0", | ||
"@ckeditor/ckeditor5-typing": "^23.1.0", | ||
"@ckeditor/ckeditor5-ui": "^23.1.0", | ||
"@ckeditor/ckeditor5-utils": "^23.1.0", | ||
"lodash-es": "^4.17.15" | ||
}, | ||
"devDependencies": { | ||
"@ckeditor/ckeditor5-basic-styles": "^23.0.0", | ||
"@ckeditor/ckeditor5-block-quote": "^23.0.0", | ||
"@ckeditor/ckeditor5-code-block": "^23.0.0", | ||
"@ckeditor/ckeditor5-editor-classic": "^23.0.0", | ||
"@ckeditor/ckeditor5-enter": "^23.0.0", | ||
"@ckeditor/ckeditor5-paragraph": "^23.0.0", | ||
"@ckeditor/ckeditor5-theme-lark": "^23.0.0", | ||
"@ckeditor/ckeditor5-undo": "^23.0.0" | ||
"@ckeditor/ckeditor5-basic-styles": "^23.1.0", | ||
"@ckeditor/ckeditor5-block-quote": "^23.1.0", | ||
"@ckeditor/ckeditor5-code-block": "^23.1.0", | ||
"@ckeditor/ckeditor5-editor-classic": "^23.1.0", | ||
"@ckeditor/ckeditor5-enter": "^23.1.0", | ||
"@ckeditor/ckeditor5-paragraph": "^23.1.0", | ||
"@ckeditor/ckeditor5-theme-lark": "^23.1.0", | ||
"@ckeditor/ckeditor5-undo": "^23.1.0" | ||
}, | ||
@@ -33,0 +33,0 @@ "engines": { |
@@ -13,2 +13,3 @@ /** | ||
import getLastTextLine from '@ckeditor/ckeditor5-typing/src/utils/getlasttextline'; | ||
import { addLinkProtocolIfApplicable } from './utils'; | ||
@@ -53,5 +54,2 @@ const MIN_LINK_LENGTH_WITH_SPACE_AT_END = 4; // Ie: "t.co " (length 5). | ||
// Simplified email test - should be run over previously found URL. | ||
const EMAIL_REG_EXP = /^[\S]+@((?![-_])(?:[-\w\u00a1-\uffff]{0,63}[^-_]\.))+(?:[a-z\u00a1-\uffff]{2,})$/i; | ||
/** | ||
@@ -218,3 +216,3 @@ * The autolink plugin. | ||
*/ | ||
_applyAutoLink( url, range ) { | ||
_applyAutoLink( link, range ) { | ||
const model = this.editor.model; | ||
@@ -228,5 +226,5 @@ | ||
model.enqueueChange( writer => { | ||
const linkHrefValue = isEmail( url ) ? `mailto:${ url }` : url; | ||
writer.setAttribute( 'linkHref', linkHrefValue, range ); | ||
const defaultProtocol = this.editor.config.get( 'link.defaultProtocol' ); | ||
const parsedUrl = addLinkProtocolIfApplicable( link, defaultProtocol ); | ||
writer.setAttribute( 'linkHref', parsedUrl, range ); | ||
} ); | ||
@@ -247,8 +245,4 @@ } | ||
function isEmail( linkHref ) { | ||
return EMAIL_REG_EXP.exec( linkHref ); | ||
} | ||
function isLinkAllowedOnRange( range, model ) { | ||
return model.schema.checkAttributeInSelection( model.createSelection( range ), 'linkHref' ); | ||
} |
@@ -12,3 +12,3 @@ /** | ||
import ClickObserver from '@ckeditor/ckeditor5-engine/src/view/observer/clickobserver'; | ||
import { isLinkElement, LINK_KEYSTROKE } from './utils'; | ||
import { addLinkProtocolIfApplicable, isLinkElement, LINK_KEYSTROKE } from './utils'; | ||
@@ -25,4 +25,2 @@ import ContextualBalloon from '@ckeditor/ckeditor5-ui/src/panel/balloon/contextualballoon'; | ||
const protocolRegExp = /^((\w+:(\/{2,})?)|(\W))/i; | ||
const emailRegExp = /[\w-]+@[\w-]+\.+[\w-]+/i; | ||
const VISUAL_SELECTION_MARKER_NAME = 'link-ui'; | ||
@@ -181,12 +179,4 @@ | ||
const { value } = formView.urlInputView.fieldView.element; | ||
// The regex checks for the protocol syntax ('xxxx://' or 'xxxx:') | ||
// or non-word characters at the beginning of the link ('/', '#' etc.). | ||
const isProtocolNeeded = !!defaultProtocol && !protocolRegExp.test( value ); | ||
const isEmail = emailRegExp.test( value ); | ||
const protocol = isEmail ? 'mailto:' : defaultProtocol; | ||
const parsedValue = value && isProtocolNeeded ? protocol + value : value; | ||
editor.execute( 'link', parsedValue, formView.getDecoratorSwitchesState() ); | ||
const parsedUrl = addLinkProtocolIfApplicable( value, defaultProtocol ); | ||
editor.execute( 'link', parsedUrl, formView.getDecoratorSwitchesState() ); | ||
this._closeFormView(); | ||
@@ -225,3 +215,5 @@ } ); | ||
this._showUI( true ); | ||
if ( linkCommand.isEnabled ) { | ||
this._showUI( true ); | ||
} | ||
} ); | ||
@@ -228,0 +220,0 @@ |
@@ -24,2 +24,3 @@ /** | ||
import '../../theme/linkactions.css'; | ||
import '@ckeditor/ckeditor5-ui/theme/components/responsive-form/responsiveform.css'; | ||
@@ -121,3 +122,4 @@ /** | ||
'ck', | ||
'ck-link-actions' | ||
'ck-link-actions', | ||
'ck-responsive-form' | ||
], | ||
@@ -124,0 +126,0 @@ |
@@ -27,2 +27,3 @@ /** | ||
import '../../theme/linkform.css'; | ||
import '@ckeditor/ckeditor5-ui/theme/components/responsive-form/responsiveform.css'; | ||
@@ -137,6 +138,6 @@ /** | ||
const classList = [ 'ck', 'ck-link-form' ]; | ||
const classList = [ 'ck', 'ck-link-form', 'ck-responsive-form' ]; | ||
if ( linkCommand.manualDecorators.length ) { | ||
classList.push( 'ck-link-form_layout-vertical' ); | ||
classList.push( 'ck-link-form_layout-vertical', 'ck-vertical-form' ); | ||
} | ||
@@ -143,0 +144,0 @@ |
@@ -15,2 +15,9 @@ /** | ||
// Simplified email test - should be run over previously found URL. | ||
const EMAIL_REG_EXP = /^[\S]+@((?![-_])(?:[-\w\u00a1-\uffff]{0,63}[^-_]\.))+(?:[a-z\u00a1-\uffff]{2,})$/i; | ||
// The regex checks for the protocol syntax ('xxxx://' or 'xxxx:') | ||
// or non-word characters at the beginning of the link ('/', '#' etc.). | ||
const PROTOCOL_REG_EXP = /^((\w+:(\/{2,})?)|(\W))/i; | ||
/** | ||
@@ -139,1 +146,30 @@ * A keystroke used by the {@link module:link/linkui~LinkUI link UI feature}. | ||
} | ||
/** | ||
* Returns `true` if the specified `value` is an email. | ||
* | ||
* @params {String} value | ||
* @returns {Boolean} | ||
*/ | ||
export function isEmail( value ) { | ||
return EMAIL_REG_EXP.test( value ); | ||
} | ||
/** | ||
* Adds protocol prefix to the specified `link` when: | ||
* | ||
* * it doesn't contain it already, and there is a {@link module:link/link~LinkConfig#defaultProtocol `defaultProtocol` } | ||
* config value provided | ||
* * or the link is an email address | ||
* | ||
* | ||
* @params {String} link | ||
* @params {String} defaultProtocol | ||
* @returns {Boolean} | ||
*/ | ||
export function addLinkProtocolIfApplicable( link, defaultProtocol ) { | ||
const protocol = isEmail( link ) ? 'mailto:' : defaultProtocol; | ||
const isProtocolNeeded = !!protocol && !PROTOCOL_REG_EXP.test( link ); | ||
return link && isProtocolNeeded ? protocol + link : link; | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
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
238978
78
3150