UNPKG

1.97 kBTypeScriptView Raw
1import { Plugin } from '@ckeditor/ckeditor5-core';
2import LinkEditing from './linkediting';
3import LinkUI from './linkui';
4import AutoLink from './autolink';
5
6/**
7 * The link plugin.
8 *
9 * This is a "glue" plugin that loads the {@link module:link/linkediting~LinkEditing link editing feature}
10 * and {@link module:link/linkui~LinkUI link UI feature}.
11 */
12export default class Link extends Plugin {
13 static readonly requires: [typeof LinkEditing, typeof LinkUI, typeof AutoLink];
14 static readonly pluginName: 'Link';
15}
16
17export interface LinkDecoratorDefinition {
18 mode: 'automatic' | 'manual';
19}
20
21export interface LinkDecoratorAutomaticDefinition extends LinkDecoratorDefinition {
22 attributes?: Record<string, string>;
23 callback(url: string): boolean;
24 mode: 'automatic';
25 classes?: string | string[];
26 styles?: Record<string, string>;
27}
28
29export interface LinkDecoratorManualDefinition extends LinkDecoratorDefinition {
30 attributes?: Record<string, string>;
31 defaultValue?: boolean | undefined;
32 label: string;
33 mode: 'manual';
34 styles?: Record<string, string>;
35 classes?: string | string[];
36}
37
38/**
39 * The configuration of the {@link module:link/link~Link} feature.
40 *
41 * Read more in {@link module:link/link~LinkConfig}.
42 */
43export interface LinkConfig {
44 addTargetToExternalLinks?: boolean | undefined;
45 decorators?: Record<string, LinkDecoratorManualDefinition | LinkDecoratorAutomaticDefinition> | undefined;
46 defaultProtocol?: string | undefined;
47}
48
49declare module '@ckeditor/ckeditor5-core/src/plugincollection' {
50 interface Plugins {
51 Link: Link;
52 }
53}
54
55declare module '@ckeditor/ckeditor5-core/src/editor/editorconfig' {
56 interface EditorConfig {
57 link?: LinkConfig | undefined;
58 'link.addTargetToExternalLinks'?: LinkConfig['addTargetToExternalLinks'];
59 'link.decorators'?: LinkConfig['decorators'];
60 'link.defaultProtocol'?: LinkConfig['defaultProtocol'];
61 }
62}