UNPKG

3.07 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/linkediting
7 */
8import { Plugin, type Editor } from 'ckeditor5/src/core.js';
9import { Input, TwoStepCaretMovement } from 'ckeditor5/src/typing.js';
10import { ClipboardPipeline } from 'ckeditor5/src/clipboard.js';
11import '../theme/link.css';
12/**
13 * The link engine feature.
14 *
15 * It introduces the `linkHref="url"` attribute in the model which renders to the view as a `<a href="url">` element
16 * as well as `'link'` and `'unlink'` commands.
17 */
18export default class LinkEditing extends Plugin {
19 /**
20 * @inheritDoc
21 */
22 static get pluginName(): "LinkEditing";
23 /**
24 * @inheritDoc
25 */
26 static get requires(): readonly [typeof TwoStepCaretMovement, typeof Input, typeof ClipboardPipeline];
27 /**
28 * @inheritDoc
29 */
30 constructor(editor: Editor);
31 /**
32 * @inheritDoc
33 */
34 init(): void;
35 /**
36 * Processes an array of configured {@link module:link/linkconfig~LinkDecoratorAutomaticDefinition automatic decorators}
37 * and registers a {@link module:engine/conversion/downcastdispatcher~DowncastDispatcher downcast dispatcher}
38 * for each one of them. Downcast dispatchers are obtained using the
39 * {@link module:link/utils/automaticdecorators~AutomaticDecorators#getDispatcher} method.
40 *
41 * **Note**: This method also activates the automatic external link decorator if enabled with
42 * {@link module:link/linkconfig~LinkConfig#addTargetToExternalLinks `config.link.addTargetToExternalLinks`}.
43 */
44 private _enableAutomaticDecorators;
45 /**
46 * Processes an array of configured {@link module:link/linkconfig~LinkDecoratorManualDefinition manual decorators},
47 * transforms them into {@link module:link/utils/manualdecorator~ManualDecorator} instances and stores them in the
48 * {@link module:link/linkcommand~LinkCommand#manualDecorators} collection (a model for manual decorators state).
49 *
50 * Also registers an {@link module:engine/conversion/downcasthelpers~DowncastHelpers#attributeToElement attribute-to-element}
51 * converter for each manual decorator and extends the {@link module:engine/model/schema~Schema model's schema}
52 * with adequate model attributes.
53 */
54 private _enableManualDecorators;
55 /**
56 * Attaches handlers for {@link module:engine/view/document~Document#event:enter} and
57 * {@link module:engine/view/document~Document#event:click} to enable link following.
58 */
59 private _enableLinkOpen;
60 /**
61 * Watches the DocumentSelection attribute changes and removes link decorator attributes when the linkHref attribute is removed.
62 *
63 * This is to ensure that there is no left-over link decorator attributes on the document selection that is no longer in a link.
64 */
65 private _enableSelectionAttributesFixer;
66 /**
67 * Enables URL fixing on pasting.
68 */
69 private _enableClipboardIntegration;
70}