link/utils
@ckeditor/ckeditor5-link/src/utils
Filtering
Constants
-
LINK_KEYSTROKE
module:link/utils~LINK_KEYSTROKE
A keystroke used by the link UI feature.
Classes
-
AutomaticDecorators
module:link/utils~AutomaticDecorators
Helper class that ties together all
LinkDecoratorAutomaticDefinition
and provides the downcast dispatchers for them. -
ManualDecorator
module:link/utils~ManualDecorator
Helper class that stores manual decorators with observable
value
to support integration with the UI state. An instance of this class is a model with the state of individual manual decorators. These decorators are kept as collections inmanualDecorators
.
Functions
-
addLinkProtocolIfApplicable() → Boolean
module:link/utils~addLinkProtocolIfApplicable
Adds the protocol prefix to the specified
link
when:- it does not contain it already, and there is a
defaultProtocol
configuration value provided, - or the link is an email address.
Returns
Boolean
- it does not contain it already, and there is a
-
createLinkElement( href, conversionApi ) → AttributeElement
module:link/utils~createLinkElement
Creates a link
AttributeElement
with the providedhref
attribute. -
ensureSafeUrl( url ) → String
module:link/utils~ensureSafeUrl
protected
Returns a safe URL based on a given value.
A URL is considered safe if it is safe for the user (does not contain any malicious code).
If a URL is considered unsafe, a simple
"#"
is returned.Parameters
url : *
Returns
String
Safe URL.
-
getLocalizedDecorators( t, The ) → Array.<LinkDecoratorDefinition>
module:link/utils~getLocalizedDecorators
Returns the
config.link.decorators
configuration processed to respect the locale of the editor, i.e. to display the label in the correct language.Note: Only the few most commonly used labels are translated automatically. Other labels should be manually translated in the
config.link.decorators
configuration.Parameters
t : Locale#t
shorthand for Locale#t
The : Array.<LinkDecoratorDefinition>
decorator reference where the label values should be localized.
Returns
Array.<LinkDecoratorDefinition>
-
isEmail() → Boolean
module:link/utils~isEmail
Returns
true
if the specifiedvalue
is an email.Returns
Boolean
-
isLinkElement( node ) → Boolean
module:link/utils~isLinkElement
Returns
true
if a given view node is the link element. -
isLinkableElement() → Boolean
module:link/utils~isLinkableElement
Returns
true
if the specifiedelement
can be linked (the element allows thelinkHref
attribute).Returns
Boolean
-
normalizeDecorators( decorators ) → Array.<LinkDecoratorDefinition>
module:link/utils~normalizeDecorators
Converts an object with defined decorators to a normalized array of decorators. The
id
key is added for each decorator and is used as the attribute's name in the model.Parameters
decorators : Object.<String, LinkDecoratorDefinition>
Returns
Array.<LinkDecoratorDefinition>
-
openLink( link )
module:link/utils~openLink
Opens the link in a new browser tab.
Parameters
link : String
Every day, we work hard to keep our documentation complete. Have you spotted an outdated information? Is something missing? Please report it via our issue tracker.