link/utils
@ckeditor/ckeditor5-link/src/utils
Filtering
Constants
-
LINK_KEYSTROKE : 'Ctrl+K'
module:link/utils#LINK_KEYSTROKE
A keystroke used by the link UI feature.
Type Definitions
-
NormalizedLinkDecoratorAutomaticDefinition
module:link/utils~NormalizedLinkDecoratorAutomaticDefinition
-
NormalizedLinkDecoratorDefinition
module:link/utils~NormalizedLinkDecoratorDefinition
-
NormalizedLinkDecoratorManualDefinition
module:link/utils~NormalizedLinkDecoratorManualDefinition
Functions
-
addLinkProtocolIfApplicable( link, [ defaultProtocol ] ) → string
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.
Parameters
link : string
[ defaultProtocol ] : string
Returns
string
- it does not contain it already, and there is a
-
createBookmarkCallbacks( editor ) → LinkActionsViewOptions
module:link/utils~createBookmarkCallbacks
Creates the bookmark callbacks for handling link opening experience.
Parameters
editor : Editor
Returns
-
createLinkElement( href, __namedParameters ) → AttributeElement
module:link/utils~createLinkElement
Creates a link
AttributeElement
with the providedhref
attribute.Parameters
href : string
__namedParameters : DowncastConversionApi
Returns
-
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 : unknown
allowedProtocols : Array<string>
-
Defaults to
DEFAULT_LINK_PROTOCOLS
Returns
string
-
getLocalizedDecorators( t, decorators ) → Array<NormalizedLinkDecoratorDefinition>
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 : LocaleTranslate
Shorthand for Locale#t.
decorators : Array<NormalizedLinkDecoratorDefinition>
The decorator reference where the label values should be localized.
Returns
-
isEmail( value ) → boolean
module:link/utils~isEmail
Returns
true
if the specifiedvalue
is an email.Parameters
value : string
Returns
boolean
-
isLinkElement( node ) → boolean
module:link/utils~isLinkElement
Returns
true
if a given view node is the link element.Parameters
node : Node | DocumentFragment
Returns
boolean
-
isLinkableElement( element, schema ) → element is Element
module:link/utils~isLinkableElement
Returns
true
if the specifiedelement
can be linked (the element allows thelinkHref
attribute).Parameters
Returns
element is Element
-
linkHasProtocol( link ) → boolean
module:link/utils~linkHasProtocol
Checks if protocol is already included in the link.
Parameters
link : string
Returns
boolean
-
normalizeDecorators( [ decorators ] ) → Array<NormalizedLinkDecoratorDefinition>
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 ] : Record<string, LinkDecoratorDefinition>
Returns
-
openLink( link ) → void
module:link/utils~openLink
Every day, we work hard to keep our documentation complete. Have you spotted outdated information? Is something missing? Please report it via our issue tracker.
With the release of version 42.0.0, we have rewritten much of our documentation to reflect the new import paths and features. We appreciate your feedback to help us ensure its accuracy and completeness.