UNPKG

2.1 kBTypeScriptView Raw
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/autolink
7 */
8import { Plugin } from 'ckeditor5/src/core.js';
9import { Delete } from 'ckeditor5/src/typing.js';
10import LinkEditing from './linkediting.js';
11/**
12 * The autolink plugin.
13 */
14export default class AutoLink extends Plugin {
15 /**
16 * @inheritDoc
17 */
18 static get requires(): readonly [typeof Delete, typeof LinkEditing];
19 /**
20 * @inheritDoc
21 */
22 static get pluginName(): "AutoLink";
23 /**
24 * @inheritDoc
25 */
26 init(): void;
27 /**
28 * @inheritDoc
29 */
30 afterInit(): void;
31 /**
32 * For given position, returns a range that includes the whole link that contains the position.
33 *
34 * If position is not inside a link, returns `null`.
35 */
36 private _expandLinkRange;
37 /**
38 * Extends the document selection to includes all links that intersects with given `selectedRange`.
39 */
40 private _selectEntireLinks;
41 /**
42 * Enables autolinking on pasting a URL when some content is selected.
43 */
44 private _enablePasteLinking;
45 /**
46 * Enables autolinking on typing.
47 */
48 private _enableTypingHandling;
49 /**
50 * Enables autolinking on the <kbd>Enter</kbd> key.
51 */
52 private _enableEnterHandling;
53 /**
54 * Enables autolinking on the <kbd>Shift</kbd>+<kbd>Enter</kbd> keyboard shortcut.
55 */
56 private _enableShiftEnterHandling;
57 /**
58 * Checks if the passed range contains a linkable text.
59 */
60 private _checkAndApplyAutoLinkOnRange;
61 /**
62 * Applies a link on a given range if the link should be applied.
63 *
64 * @param url The URL to link.
65 * @param range The text range to apply the link attribute to.
66 */
67 private _applyAutoLink;
68 /**
69 * Enqueues autolink changes in the model.
70 *
71 * @param url The URL to link.
72 * @param range The text range to apply the link attribute to.
73 */
74 private _persistAutoLink;
75}