@ckeditor/ckeditor5-link 41.2.0 → 41.3.0-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,80 @@
1
+ /**
2
+ * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
3
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
+ */
5
+ /**
6
+ * @module link/utils
7
+ */
8
+ import type { DowncastConversionApi, Element, Schema, ViewAttributeElement, ViewNode, ViewDocumentFragment } from 'ckeditor5/src/engine.js';
9
+ import type { LocaleTranslate } from 'ckeditor5/src/utils.js';
10
+ import type { LinkDecoratorAutomaticDefinition, LinkDecoratorDefinition, LinkDecoratorManualDefinition } from './linkconfig.js';
11
+ /**
12
+ * A keystroke used by the {@link module:link/linkui~LinkUI link UI feature}.
13
+ */
14
+ export declare const LINK_KEYSTROKE = "Ctrl+K";
15
+ /**
16
+ * Returns `true` if a given view node is the link element.
17
+ */
18
+ export declare function isLinkElement(node: ViewNode | ViewDocumentFragment): boolean;
19
+ /**
20
+ * Creates a link {@link module:engine/view/attributeelement~AttributeElement} with the provided `href` attribute.
21
+ */
22
+ export declare function createLinkElement(href: string, { writer }: DowncastConversionApi): ViewAttributeElement;
23
+ /**
24
+ * Returns a safe URL based on a given value.
25
+ *
26
+ * A URL is considered safe if it is safe for the user (does not contain any malicious code).
27
+ *
28
+ * If a URL is considered unsafe, a simple `"#"` is returned.
29
+ *
30
+ * @internal
31
+ */
32
+ export declare function ensureSafeUrl(url: unknown, allowedProtocols?: Array<string>): string;
33
+ /**
34
+ * Returns the {@link module:link/linkconfig~LinkConfig#decorators `config.link.decorators`} configuration processed
35
+ * to respect the locale of the editor, i.e. to display the {@link module:link/linkconfig~LinkDecoratorManualDefinition label}
36
+ * in the correct language.
37
+ *
38
+ * **Note**: Only the few most commonly used labels are translated automatically. Other labels should be manually
39
+ * translated in the {@link module:link/linkconfig~LinkConfig#decorators `config.link.decorators`} configuration.
40
+ *
41
+ * @param t Shorthand for {@link module:utils/locale~Locale#t Locale#t}.
42
+ * @param decorators The decorator reference where the label values should be localized.
43
+ */
44
+ export declare function getLocalizedDecorators(t: LocaleTranslate, decorators: Array<NormalizedLinkDecoratorDefinition>): Array<NormalizedLinkDecoratorDefinition>;
45
+ /**
46
+ * Converts an object with defined decorators to a normalized array of decorators. The `id` key is added for each decorator and
47
+ * is used as the attribute's name in the model.
48
+ */
49
+ export declare function normalizeDecorators(decorators?: Record<string, LinkDecoratorDefinition>): Array<NormalizedLinkDecoratorDefinition>;
50
+ /**
51
+ * Returns `true` if the specified `element` can be linked (the element allows the `linkHref` attribute).
52
+ */
53
+ export declare function isLinkableElement(element: Element | null, schema: Schema): element is Element;
54
+ /**
55
+ * Returns `true` if the specified `value` is an email.
56
+ */
57
+ export declare function isEmail(value: string): boolean;
58
+ /**
59
+ * Adds the protocol prefix to the specified `link` when:
60
+ *
61
+ * * it does not contain it already, and there is a {@link module:link/linkconfig~LinkConfig#defaultProtocol `defaultProtocol` }
62
+ * configuration value provided,
63
+ * * or the link is an email address.
64
+ */
65
+ export declare function addLinkProtocolIfApplicable(link: string, defaultProtocol?: string): string;
66
+ /**
67
+ * Checks if protocol is already included in the link.
68
+ */
69
+ export declare function linkHasProtocol(link: string): boolean;
70
+ /**
71
+ * Opens the link in a new browser tab.
72
+ */
73
+ export declare function openLink(link: string): void;
74
+ export type NormalizedLinkDecoratorAutomaticDefinition = LinkDecoratorAutomaticDefinition & {
75
+ id: string;
76
+ };
77
+ export type NormalizedLinkDecoratorManualDefinition = LinkDecoratorManualDefinition & {
78
+ id: string;
79
+ };
80
+ export type NormalizedLinkDecoratorDefinition = NormalizedLinkDecoratorAutomaticDefinition | NormalizedLinkDecoratorManualDefinition;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ckeditor/ckeditor5-link",
3
- "version": "41.2.0",
3
+ "version": "41.3.0-alpha.0",
4
4
  "description": "Link feature for CKEditor 5.",
5
5
  "keywords": [
6
6
  "ckeditor",
@@ -13,8 +13,8 @@
13
13
  "type": "module",
14
14
  "main": "src/index.js",
15
15
  "dependencies": {
16
- "@ckeditor/ckeditor5-ui": "41.2.0",
17
- "ckeditor5": "41.2.0",
16
+ "@ckeditor/ckeditor5-ui": "41.3.0-alpha.0",
17
+ "ckeditor5": "41.3.0-alpha.0",
18
18
  "lodash-es": "4.17.21"
19
19
  },
20
20
  "author": "CKSource (http://cksource.com/)",
@@ -27,6 +27,7 @@
27
27
  "directory": "packages/ckeditor5-link"
28
28
  },
29
29
  "files": [
30
+ "dist",
30
31
  "lang",
31
32
  "src/**/*.js",
32
33
  "src/**/*.d.ts",
package/src/index.d.ts CHANGED
@@ -12,7 +12,7 @@ export { default as LinkImage } from './linkimage.js';
12
12
  export { default as LinkImageEditing } from './linkimageediting.js';
13
13
  export { default as LinkImageUI } from './linkimageui.js';
14
14
  export { default as AutoLink } from './autolink.js';
15
- export { LinkConfig, type LinkDecoratorDefinition } from './linkconfig.js';
15
+ export type { LinkConfig, LinkDecoratorDefinition } from './linkconfig.js';
16
16
  export { default as LinkCommand } from './linkcommand.js';
17
17
  export { default as UnlinkCommand } from './unlinkcommand.js';
18
18
  import './augmentation.js';