@ckeditor/ckeditor5-link 41.3.1 → 41.4.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.
Files changed (155) hide show
  1. package/build/link.js +1 -1
  2. package/dist/index-content.css +4 -0
  3. package/dist/index-editor.css +44 -0
  4. package/dist/index.css +148 -0
  5. package/dist/index.css.map +1 -0
  6. package/dist/index.js +2422 -0
  7. package/dist/index.js.map +1 -0
  8. package/dist/translations/ar.d.ts +8 -0
  9. package/dist/translations/ar.js +5 -0
  10. package/dist/translations/ast.d.ts +8 -0
  11. package/dist/translations/ast.js +5 -0
  12. package/dist/translations/az.d.ts +8 -0
  13. package/dist/translations/az.js +5 -0
  14. package/dist/translations/bg.d.ts +8 -0
  15. package/dist/translations/bg.js +5 -0
  16. package/dist/translations/bn.d.ts +8 -0
  17. package/dist/translations/bn.js +5 -0
  18. package/dist/translations/ca.d.ts +8 -0
  19. package/dist/translations/ca.js +5 -0
  20. package/dist/translations/cs.d.ts +8 -0
  21. package/dist/translations/cs.js +5 -0
  22. package/dist/translations/da.d.ts +8 -0
  23. package/dist/translations/da.js +5 -0
  24. package/dist/translations/de-ch.d.ts +8 -0
  25. package/dist/translations/de-ch.js +5 -0
  26. package/dist/translations/de.d.ts +8 -0
  27. package/dist/translations/de.js +5 -0
  28. package/dist/translations/el.d.ts +8 -0
  29. package/dist/translations/el.js +5 -0
  30. package/dist/translations/en-au.d.ts +8 -0
  31. package/dist/translations/en-au.js +5 -0
  32. package/dist/translations/en-gb.d.ts +8 -0
  33. package/dist/translations/en-gb.js +5 -0
  34. package/dist/translations/en.d.ts +8 -0
  35. package/dist/translations/en.js +5 -0
  36. package/dist/translations/eo.d.ts +8 -0
  37. package/dist/translations/eo.js +5 -0
  38. package/dist/translations/es.d.ts +8 -0
  39. package/dist/translations/es.js +5 -0
  40. package/dist/translations/et.d.ts +8 -0
  41. package/dist/translations/et.js +5 -0
  42. package/dist/translations/eu.d.ts +8 -0
  43. package/dist/translations/eu.js +5 -0
  44. package/dist/translations/fa.d.ts +8 -0
  45. package/dist/translations/fa.js +5 -0
  46. package/dist/translations/fi.d.ts +8 -0
  47. package/dist/translations/fi.js +5 -0
  48. package/dist/translations/fr.d.ts +8 -0
  49. package/dist/translations/fr.js +5 -0
  50. package/dist/translations/gl.d.ts +8 -0
  51. package/dist/translations/gl.js +5 -0
  52. package/dist/translations/he.d.ts +8 -0
  53. package/dist/translations/he.js +5 -0
  54. package/dist/translations/hi.d.ts +8 -0
  55. package/dist/translations/hi.js +5 -0
  56. package/dist/translations/hr.d.ts +8 -0
  57. package/dist/translations/hr.js +5 -0
  58. package/dist/translations/hu.d.ts +8 -0
  59. package/dist/translations/hu.js +5 -0
  60. package/dist/translations/hy.d.ts +8 -0
  61. package/dist/translations/hy.js +5 -0
  62. package/dist/translations/id.d.ts +8 -0
  63. package/dist/translations/id.js +5 -0
  64. package/dist/translations/it.d.ts +8 -0
  65. package/dist/translations/it.js +5 -0
  66. package/dist/translations/ja.d.ts +8 -0
  67. package/dist/translations/ja.js +5 -0
  68. package/dist/translations/km.d.ts +8 -0
  69. package/dist/translations/km.js +5 -0
  70. package/dist/translations/kn.d.ts +8 -0
  71. package/dist/translations/kn.js +5 -0
  72. package/dist/translations/ko.d.ts +8 -0
  73. package/dist/translations/ko.js +5 -0
  74. package/dist/translations/ku.d.ts +8 -0
  75. package/dist/translations/ku.js +5 -0
  76. package/dist/translations/lt.d.ts +8 -0
  77. package/dist/translations/lt.js +5 -0
  78. package/dist/translations/lv.d.ts +8 -0
  79. package/dist/translations/lv.js +5 -0
  80. package/dist/translations/ms.d.ts +8 -0
  81. package/dist/translations/ms.js +5 -0
  82. package/dist/translations/nb.d.ts +8 -0
  83. package/dist/translations/nb.js +5 -0
  84. package/dist/translations/ne.d.ts +8 -0
  85. package/dist/translations/ne.js +5 -0
  86. package/dist/translations/nl.d.ts +8 -0
  87. package/dist/translations/nl.js +5 -0
  88. package/dist/translations/no.d.ts +8 -0
  89. package/dist/translations/no.js +5 -0
  90. package/dist/translations/pl.d.ts +8 -0
  91. package/dist/translations/pl.js +5 -0
  92. package/dist/translations/pt-br.d.ts +8 -0
  93. package/dist/translations/pt-br.js +5 -0
  94. package/dist/translations/pt.d.ts +8 -0
  95. package/dist/translations/pt.js +5 -0
  96. package/dist/translations/ro.d.ts +8 -0
  97. package/dist/translations/ro.js +5 -0
  98. package/dist/translations/ru.d.ts +8 -0
  99. package/dist/translations/ru.js +5 -0
  100. package/dist/translations/sk.d.ts +8 -0
  101. package/dist/translations/sk.js +5 -0
  102. package/dist/translations/sq.d.ts +8 -0
  103. package/dist/translations/sq.js +5 -0
  104. package/dist/translations/sr-latn.d.ts +8 -0
  105. package/dist/translations/sr-latn.js +5 -0
  106. package/dist/translations/sr.d.ts +8 -0
  107. package/dist/translations/sr.js +5 -0
  108. package/dist/translations/sv.d.ts +8 -0
  109. package/dist/translations/sv.js +5 -0
  110. package/dist/translations/th.d.ts +8 -0
  111. package/dist/translations/th.js +5 -0
  112. package/dist/translations/tk.d.ts +8 -0
  113. package/dist/translations/tk.js +5 -0
  114. package/dist/translations/tr.d.ts +8 -0
  115. package/dist/translations/tr.js +5 -0
  116. package/dist/translations/tt.d.ts +8 -0
  117. package/dist/translations/tt.js +5 -0
  118. package/dist/translations/ug.d.ts +8 -0
  119. package/dist/translations/ug.js +5 -0
  120. package/dist/translations/uk.d.ts +8 -0
  121. package/dist/translations/uk.js +5 -0
  122. package/dist/translations/ur.d.ts +8 -0
  123. package/dist/translations/ur.js +5 -0
  124. package/dist/translations/uz.d.ts +8 -0
  125. package/dist/translations/uz.js +5 -0
  126. package/dist/translations/vi.d.ts +8 -0
  127. package/dist/translations/vi.js +5 -0
  128. package/dist/translations/zh-cn.d.ts +8 -0
  129. package/dist/translations/zh-cn.js +5 -0
  130. package/dist/translations/zh.d.ts +8 -0
  131. package/dist/translations/zh.js +5 -0
  132. package/dist/types/augmentation.d.ts +34 -0
  133. package/dist/types/autolink.d.ts +79 -0
  134. package/dist/types/index.d.ts +22 -0
  135. package/dist/types/link.d.ts +31 -0
  136. package/dist/types/linkcommand.d.ts +136 -0
  137. package/dist/types/linkconfig.d.ts +294 -0
  138. package/dist/types/linkediting.d.ts +74 -0
  139. package/dist/types/linkimage.d.ts +31 -0
  140. package/dist/types/linkimageediting.d.ts +43 -0
  141. package/dist/types/linkimageui.d.ts +44 -0
  142. package/dist/types/linkui.d.ts +173 -0
  143. package/dist/types/ui/linkactionsview.d.ts +107 -0
  144. package/dist/types/ui/linkformview.d.ts +175 -0
  145. package/dist/types/unlinkcommand.d.ts +35 -0
  146. package/dist/types/utils/automaticdecorators.d.ts +49 -0
  147. package/dist/types/utils/manualdecorator.d.ts +76 -0
  148. package/dist/types/utils.d.ts +84 -0
  149. package/lang/contexts.json +1 -0
  150. package/package.json +4 -3
  151. package/src/index.d.ts +1 -1
  152. package/src/linkui.js +30 -8
  153. package/src/ui/linkformview.d.ts +31 -1
  154. package/src/ui/linkformview.js +41 -1
  155. package/theme/linkform.css +1 -0
@@ -0,0 +1,43 @@
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
+ * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
7
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
8
+ */
9
+ /**
10
+ * @module link/linkimageediting
11
+ */
12
+ import { Plugin } from 'ckeditor5/src/core.js';
13
+ import LinkEditing from './linkediting.js';
14
+ /**
15
+ * The link image engine feature.
16
+ *
17
+ * It accepts the `linkHref="url"` attribute in the model for the {@link module:image/image~Image `<imageBlock>`} element
18
+ * which allows linking images.
19
+ */
20
+ export default class LinkImageEditing extends Plugin {
21
+ /**
22
+ * @inheritDoc
23
+ */
24
+ static get requires(): readonly ["ImageEditing", "ImageUtils", typeof LinkEditing];
25
+ /**
26
+ * @inheritDoc
27
+ */
28
+ static get pluginName(): "LinkImageEditing";
29
+ /**
30
+ * @inheritDoc
31
+ */
32
+ afterInit(): void;
33
+ /**
34
+ * Processes {@link module:link/linkconfig~LinkDecoratorAutomaticDefinition automatic decorators} definitions and
35
+ * attaches proper converters that will work when linking an image.`
36
+ */
37
+ private _enableAutomaticDecorators;
38
+ /**
39
+ * Processes transformed {@link module:link/utils/manualdecorator~ManualDecorator} instances and attaches proper converters
40
+ * that will work when linking an image.
41
+ */
42
+ private _enableManualDecorators;
43
+ }
@@ -0,0 +1,44 @@
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
+ * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
7
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
8
+ */
9
+ import { Plugin } from 'ckeditor5/src/core.js';
10
+ import LinkUI from './linkui.js';
11
+ import LinkEditing from './linkediting.js';
12
+ /**
13
+ * The link image UI plugin.
14
+ *
15
+ * This plugin provides the `'linkImage'` button that can be displayed in the {@link module:image/imagetoolbar~ImageToolbar}.
16
+ * It can be used to wrap images in links.
17
+ */
18
+ export default class LinkImageUI extends Plugin {
19
+ /**
20
+ * @inheritDoc
21
+ */
22
+ static get requires(): readonly [typeof LinkEditing, typeof LinkUI, "ImageBlockEditing"];
23
+ /**
24
+ * @inheritDoc
25
+ */
26
+ static get pluginName(): "LinkImageUI";
27
+ /**
28
+ * @inheritDoc
29
+ */
30
+ init(): void;
31
+ /**
32
+ * Creates a `LinkImageUI` button view.
33
+ *
34
+ * Clicking this button shows a {@link module:link/linkui~LinkUI#_balloon} attached to the selection.
35
+ * When an image is already linked, the view shows {@link module:link/linkui~LinkUI#actionsView} or
36
+ * {@link module:link/linkui~LinkUI#formView} if it is not.
37
+ */
38
+ private _createToolbarLinkImageButton;
39
+ /**
40
+ * Returns true if a linked image (either block or inline) is the only selected element
41
+ * in the model document.
42
+ */
43
+ private _isSelectedLinkedImage;
44
+ }
@@ -0,0 +1,173 @@
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
+ * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
7
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
8
+ */
9
+ /**
10
+ * @module link/linkui
11
+ */
12
+ import { Plugin } from 'ckeditor5/src/core.js';
13
+ import { ContextualBalloon, type ViewWithCssTransitionDisabler } from 'ckeditor5/src/ui.js';
14
+ import LinkFormView from './ui/linkformview.js';
15
+ import LinkActionsView from './ui/linkactionsview.js';
16
+ /**
17
+ * The link UI plugin. It introduces the `'link'` and `'unlink'` buttons and support for the <kbd>Ctrl+K</kbd> keystroke.
18
+ *
19
+ * It uses the
20
+ * {@link module:ui/panel/balloon/contextualballoon~ContextualBalloon contextual balloon plugin}.
21
+ */
22
+ export default class LinkUI extends Plugin {
23
+ /**
24
+ * The actions view displayed inside of the balloon.
25
+ */
26
+ actionsView: LinkActionsView | null;
27
+ /**
28
+ * The form view displayed inside the balloon.
29
+ */
30
+ formView: LinkFormView & ViewWithCssTransitionDisabler | null;
31
+ /**
32
+ * The contextual balloon plugin instance.
33
+ */
34
+ private _balloon;
35
+ /**
36
+ * @inheritDoc
37
+ */
38
+ static get requires(): readonly [typeof ContextualBalloon];
39
+ /**
40
+ * @inheritDoc
41
+ */
42
+ static get pluginName(): "LinkUI";
43
+ /**
44
+ * @inheritDoc
45
+ */
46
+ init(): void;
47
+ /**
48
+ * @inheritDoc
49
+ */
50
+ destroy(): void;
51
+ /**
52
+ * Creates views.
53
+ */
54
+ private _createViews;
55
+ /**
56
+ * Creates the {@link module:link/ui/linkactionsview~LinkActionsView} instance.
57
+ */
58
+ private _createActionsView;
59
+ /**
60
+ * Creates the {@link module:link/ui/linkformview~LinkFormView} instance.
61
+ */
62
+ private _createFormView;
63
+ /**
64
+ * Creates a toolbar Link button. Clicking this button will show
65
+ * a {@link #_balloon} attached to the selection.
66
+ */
67
+ private _createToolbarLinkButton;
68
+ /**
69
+ * Creates a button for link command to use either in toolbar or in menu bar.
70
+ */
71
+ private _createButton;
72
+ /**
73
+ * Attaches actions that control whether the balloon panel containing the
74
+ * {@link #formView} should be displayed.
75
+ */
76
+ private _enableBalloonActivators;
77
+ /**
78
+ * Attaches actions that control whether the balloon panel containing the
79
+ * {@link #formView} is visible or not.
80
+ */
81
+ private _enableUserBalloonInteractions;
82
+ /**
83
+ * Adds the {@link #actionsView} to the {@link #_balloon}.
84
+ *
85
+ * @internal
86
+ */
87
+ _addActionsView(): void;
88
+ /**
89
+ * Adds the {@link #formView} to the {@link #_balloon}.
90
+ */
91
+ private _addFormView;
92
+ /**
93
+ * Closes the form view. Decides whether the balloon should be hidden completely or if the action view should be shown. This is
94
+ * decided upon the link command value (which has a value if the document selection is in the link).
95
+ *
96
+ * Additionally, if any {@link module:link/linkconfig~LinkConfig#decorators} are defined in the editor configuration, the state of
97
+ * switch buttons responsible for manual decorator handling is restored.
98
+ */
99
+ private _closeFormView;
100
+ /**
101
+ * Removes the {@link #formView} from the {@link #_balloon}.
102
+ */
103
+ private _removeFormView;
104
+ /**
105
+ * Shows the correct UI type. It is either {@link #formView} or {@link #actionsView}.
106
+ *
107
+ * @internal
108
+ */
109
+ _showUI(forceVisible?: boolean): void;
110
+ /**
111
+ * Removes the {@link #formView} from the {@link #_balloon}.
112
+ *
113
+ * See {@link #_addFormView}, {@link #_addActionsView}.
114
+ */
115
+ private _hideUI;
116
+ /**
117
+ * Makes the UI react to the {@link module:ui/editorui/editorui~EditorUI#event:update} event to
118
+ * reposition itself when the editor UI should be refreshed.
119
+ *
120
+ * See: {@link #_hideUI} to learn when the UI stops reacting to the `update` event.
121
+ */
122
+ private _startUpdatingUI;
123
+ /**
124
+ * Returns `true` when {@link #formView} is in the {@link #_balloon}.
125
+ */
126
+ private get _isFormInPanel();
127
+ /**
128
+ * Returns `true` when {@link #actionsView} is in the {@link #_balloon}.
129
+ */
130
+ private get _areActionsInPanel();
131
+ /**
132
+ * Returns `true` when {@link #actionsView} is in the {@link #_balloon} and it is
133
+ * currently visible.
134
+ */
135
+ private get _areActionsVisible();
136
+ /**
137
+ * Returns `true` when {@link #actionsView} or {@link #formView} is in the {@link #_balloon}.
138
+ */
139
+ private get _isUIInPanel();
140
+ /**
141
+ * Returns `true` when {@link #actionsView} or {@link #formView} is in the {@link #_balloon} and it is
142
+ * currently visible.
143
+ */
144
+ private get _isUIVisible();
145
+ /**
146
+ * Returns positioning options for the {@link #_balloon}. They control the way the balloon is attached
147
+ * to the target element or selection.
148
+ *
149
+ * If the selection is collapsed and inside a link element, the panel will be attached to the
150
+ * entire link element. Otherwise, it will be attached to the selection.
151
+ */
152
+ private _getBalloonPositionData;
153
+ /**
154
+ * Returns the link {@link module:engine/view/attributeelement~AttributeElement} under
155
+ * the {@link module:engine/view/document~Document editing view's} selection or `null`
156
+ * if there is none.
157
+ *
158
+ * **Note**: For a non–collapsed selection, the link element is returned when **fully**
159
+ * selected and the **only** element within the selection boundaries, or when
160
+ * a linked widget is selected.
161
+ */
162
+ private _getSelectedLinkElement;
163
+ /**
164
+ * Displays a fake visual selection when the contextual balloon is displayed.
165
+ *
166
+ * This adds a 'link-ui' marker into the document that is rendered as a highlight on selected text fragment.
167
+ */
168
+ private _showFakeVisualSelection;
169
+ /**
170
+ * Hides the fake visual selection created in {@link #_showFakeVisualSelection}.
171
+ */
172
+ private _hideFakeVisualSelection;
173
+ }
@@ -0,0 +1,107 @@
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
+ * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
7
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
8
+ */
9
+ /**
10
+ * @module link/ui/linkactionsview
11
+ */
12
+ import { ButtonView, View } from 'ckeditor5/src/ui.js';
13
+ import { FocusTracker, KeystrokeHandler, type LocaleTranslate, type Locale } from 'ckeditor5/src/utils.js';
14
+ import '@ckeditor/ckeditor5-ui/theme/components/responsive-form/responsiveform.css';
15
+ import '../../theme/linkactions.css';
16
+ import type { LinkConfig } from '../linkconfig.js';
17
+ /**
18
+ * The link actions view class. This view displays the link preview, allows
19
+ * unlinking or editing the link.
20
+ */
21
+ export default class LinkActionsView extends View {
22
+ /**
23
+ * Tracks information about DOM focus in the actions.
24
+ */
25
+ readonly focusTracker: FocusTracker;
26
+ /**
27
+ * An instance of the {@link module:utils/keystrokehandler~KeystrokeHandler}.
28
+ */
29
+ readonly keystrokes: KeystrokeHandler;
30
+ /**
31
+ * The href preview view.
32
+ */
33
+ previewButtonView: ButtonView;
34
+ /**
35
+ * The unlink button view.
36
+ */
37
+ unlinkButtonView: ButtonView;
38
+ /**
39
+ * The edit link button view.
40
+ */
41
+ editButtonView: ButtonView;
42
+ /**
43
+ * The value of the "href" attribute of the link to use in the {@link #previewButtonView}.
44
+ *
45
+ * @observable
46
+ */
47
+ href: string | undefined;
48
+ /**
49
+ * A collection of views that can be focused in the view.
50
+ */
51
+ private readonly _focusables;
52
+ /**
53
+ * Helps cycling over {@link #_focusables} in the view.
54
+ */
55
+ private readonly _focusCycler;
56
+ private readonly _linkConfig;
57
+ t: LocaleTranslate;
58
+ /**
59
+ * @inheritDoc
60
+ */
61
+ constructor(locale: Locale, linkConfig?: LinkConfig);
62
+ /**
63
+ * @inheritDoc
64
+ */
65
+ render(): void;
66
+ /**
67
+ * @inheritDoc
68
+ */
69
+ destroy(): void;
70
+ /**
71
+ * Focuses the fist {@link #_focusables} in the actions.
72
+ */
73
+ focus(): void;
74
+ /**
75
+ * Creates a button view.
76
+ *
77
+ * @param label The button label.
78
+ * @param icon The button icon.
79
+ * @param eventName An event name that the `ButtonView#execute` event will be delegated to.
80
+ * @returns The button view instance.
81
+ */
82
+ private _createButton;
83
+ /**
84
+ * Creates a link href preview button.
85
+ *
86
+ * @returns The button view instance.
87
+ */
88
+ private _createPreviewButton;
89
+ }
90
+ /**
91
+ * Fired when the {@link ~LinkActionsView#editButtonView} is clicked.
92
+ *
93
+ * @eventName ~LinkActionsView#edit
94
+ */
95
+ export type EditEvent = {
96
+ name: 'edit';
97
+ args: [];
98
+ };
99
+ /**
100
+ * Fired when the {@link ~LinkActionsView#unlinkButtonView} is clicked.
101
+ *
102
+ * @eventName ~LinkActionsView#unlink
103
+ */
104
+ export type UnlinkEvent = {
105
+ name: 'unlink';
106
+ args: [];
107
+ };
@@ -0,0 +1,175 @@
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
+ * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
7
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
8
+ */
9
+ /**
10
+ * @module link/ui/linkformview
11
+ */
12
+ import { ButtonView, LabeledFieldView, View, ViewCollection, type InputTextView } from 'ckeditor5/src/ui.js';
13
+ import { FocusTracker, KeystrokeHandler, type Locale } from 'ckeditor5/src/utils.js';
14
+ import type LinkCommand from '../linkcommand.js';
15
+ import '@ckeditor/ckeditor5-ui/theme/components/responsive-form/responsiveform.css';
16
+ import '../../theme/linkform.css';
17
+ /**
18
+ * The link form view controller class.
19
+ *
20
+ * See {@link module:link/ui/linkformview~LinkFormView}.
21
+ */
22
+ export default class LinkFormView extends View {
23
+ /**
24
+ * Tracks information about DOM focus in the form.
25
+ */
26
+ readonly focusTracker: FocusTracker;
27
+ /**
28
+ * An instance of the {@link module:utils/keystrokehandler~KeystrokeHandler}.
29
+ */
30
+ readonly keystrokes: KeystrokeHandler;
31
+ /**
32
+ * The URL input view.
33
+ */
34
+ urlInputView: LabeledFieldView<InputTextView>;
35
+ /**
36
+ * The Save button view.
37
+ */
38
+ saveButtonView: ButtonView;
39
+ /**
40
+ * The Cancel button view.
41
+ */
42
+ cancelButtonView: ButtonView;
43
+ /**
44
+ * A collection of {@link module:ui/button/switchbuttonview~SwitchButtonView},
45
+ * which corresponds to {@link module:link/linkcommand~LinkCommand#manualDecorators manual decorators}
46
+ * configured in the editor.
47
+ */
48
+ private readonly _manualDecoratorSwitches;
49
+ /**
50
+ * A collection of child views in the form.
51
+ */
52
+ readonly children: ViewCollection;
53
+ /**
54
+ * An array of form validators used by {@link #isValid}.
55
+ */
56
+ private readonly _validators;
57
+ /**
58
+ * A collection of views that can be focused in the form.
59
+ */
60
+ private readonly _focusables;
61
+ /**
62
+ * Helps cycling over {@link #_focusables} in the form.
63
+ */
64
+ private readonly _focusCycler;
65
+ /**
66
+ * Creates an instance of the {@link module:link/ui/linkformview~LinkFormView} class.
67
+ *
68
+ * Also see {@link #render}.
69
+ *
70
+ * @param locale The localization services instance.
71
+ * @param linkCommand Reference to {@link module:link/linkcommand~LinkCommand}.
72
+ * @param validators Form validators used by {@link #isValid}.
73
+ */
74
+ constructor(locale: Locale, linkCommand: LinkCommand, validators: Array<LinkFormValidatorCallback>);
75
+ /**
76
+ * Obtains the state of the {@link module:ui/button/switchbuttonview~SwitchButtonView switch buttons} representing
77
+ * {@link module:link/linkcommand~LinkCommand#manualDecorators manual link decorators}
78
+ * in the {@link module:link/ui/linkformview~LinkFormView}.
79
+ *
80
+ * @returns Key-value pairs, where the key is the name of the decorator and the value is its state.
81
+ */
82
+ getDecoratorSwitchesState(): Record<string, boolean>;
83
+ /**
84
+ * @inheritDoc
85
+ */
86
+ render(): void;
87
+ /**
88
+ * @inheritDoc
89
+ */
90
+ destroy(): void;
91
+ /**
92
+ * Focuses the fist {@link #_focusables} in the form.
93
+ */
94
+ focus(): void;
95
+ /**
96
+ * Validates the form and returns `false` when some fields are invalid.
97
+ */
98
+ isValid(): boolean;
99
+ /**
100
+ * Cleans up the supplementary error and information text of the {@link #urlInputView}
101
+ * bringing them back to the state when the form has been displayed for the first time.
102
+ *
103
+ * See {@link #isValid}.
104
+ */
105
+ resetFormStatus(): void;
106
+ /**
107
+ * Creates a labeled input view.
108
+ *
109
+ * @returns Labeled field view instance.
110
+ */
111
+ private _createUrlInput;
112
+ /**
113
+ * Creates a button view.
114
+ *
115
+ * @param label The button label.
116
+ * @param icon The button icon.
117
+ * @param className The additional button CSS class name.
118
+ * @param eventName An event name that the `ButtonView#execute` event will be delegated to.
119
+ * @returns The button view instance.
120
+ */
121
+ private _createButton;
122
+ /**
123
+ * Populates {@link module:ui/viewcollection~ViewCollection} of {@link module:ui/button/switchbuttonview~SwitchButtonView}
124
+ * made based on {@link module:link/linkcommand~LinkCommand#manualDecorators}.
125
+ *
126
+ * @param linkCommand A reference to the link command.
127
+ * @returns ViewCollection of switch buttons.
128
+ */
129
+ private _createManualDecoratorSwitches;
130
+ /**
131
+ * Populates the {@link #children} collection of the form.
132
+ *
133
+ * If {@link module:link/linkcommand~LinkCommand#manualDecorators manual decorators} are configured in the editor, it creates an
134
+ * additional `View` wrapping all {@link #_manualDecoratorSwitches} switch buttons corresponding
135
+ * to these decorators.
136
+ *
137
+ * @param manualDecorators A reference to
138
+ * the collection of manual decorators stored in the link command.
139
+ * @returns The children of link form view.
140
+ */
141
+ private _createFormChildren;
142
+ /**
143
+ * The native DOM `value` of the {@link #urlInputView} element.
144
+ *
145
+ * **Note**: Do not confuse it with the {@link module:ui/inputtext/inputtextview~InputTextView#value}
146
+ * which works one way only and may not represent the actual state of the component in the DOM.
147
+ */
148
+ get url(): string | null;
149
+ }
150
+ /**
151
+ * Callback used by {@link ~LinkFormView} to check if passed form value is valid.
152
+ *
153
+ * * If `undefined` is returned, it is assumed that the form value is correct and there is no error.
154
+ * * If string is returned, it is assumed that the form value is incorrect and the returned string is displayed in the error label
155
+ */
156
+ export type LinkFormValidatorCallback = (form: LinkFormView) => string | undefined;
157
+ /**
158
+ * Fired when the form view is submitted (when one of the children triggered the submit event),
159
+ * for example with a click on {@link ~LinkFormView#saveButtonView}.
160
+ *
161
+ * @eventName ~LinkFormView#submit
162
+ */
163
+ export type SubmitEvent = {
164
+ name: 'submit';
165
+ args: [];
166
+ };
167
+ /**
168
+ * Fired when the form view is canceled, for example with a click on {@link ~LinkFormView#cancelButtonView}.
169
+ *
170
+ * @eventName ~LinkFormView#cancel
171
+ */
172
+ export type CancelEvent = {
173
+ name: 'cancel';
174
+ args: [];
175
+ };
@@ -0,0 +1,35 @@
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
+ * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
7
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
8
+ */
9
+ /**
10
+ * @module link/unlinkcommand
11
+ */
12
+ import { Command } from 'ckeditor5/src/core.js';
13
+ /**
14
+ * The unlink command. It is used by the {@link module:link/link~Link link plugin}.
15
+ */
16
+ export default class UnlinkCommand extends Command {
17
+ /**
18
+ * @inheritDoc
19
+ */
20
+ refresh(): void;
21
+ /**
22
+ * Executes the command.
23
+ *
24
+ * When the selection is collapsed, it removes the `linkHref` attribute from each node with the same `linkHref` attribute value.
25
+ * When the selection is non-collapsed, it removes the `linkHref` attribute from each node in selected ranges.
26
+ *
27
+ * # Decorators
28
+ *
29
+ * If {@link module:link/linkconfig~LinkConfig#decorators `config.link.decorators`} is specified,
30
+ * all configured decorators are removed together with the `linkHref` attribute.
31
+ *
32
+ * @fires execute
33
+ */
34
+ execute(): void;
35
+ }
@@ -0,0 +1,49 @@
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
+ * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
7
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
8
+ */
9
+ /**
10
+ * @module link/utils/automaticdecorators
11
+ */
12
+ import { type ArrayOrItem } from 'ckeditor5/src/utils.js';
13
+ import type { DowncastDispatcher } from 'ckeditor5/src/engine.js';
14
+ import type { NormalizedLinkDecoratorAutomaticDefinition } from '../utils.js';
15
+ /**
16
+ * Helper class that ties together all {@link module:link/linkconfig~LinkDecoratorAutomaticDefinition} and provides
17
+ * the {@link module:engine/conversion/downcasthelpers~DowncastHelpers#attributeToElement downcast dispatchers} for them.
18
+ */
19
+ export default class AutomaticDecorators {
20
+ /**
21
+ * Stores the definition of {@link module:link/linkconfig~LinkDecoratorAutomaticDefinition automatic decorators}.
22
+ * This data is used as a source for a downcast dispatcher to create a proper conversion to output data.
23
+ */
24
+ private _definitions;
25
+ /**
26
+ * Gives information about the number of decorators stored in the {@link module:link/utils/automaticdecorators~AutomaticDecorators}
27
+ * instance.
28
+ */
29
+ get length(): number;
30
+ /**
31
+ * Adds automatic decorator objects or an array with them to be used during downcasting.
32
+ *
33
+ * @param item A configuration object of automatic rules for decorating links. It might also be an array of such objects.
34
+ */
35
+ add(item: ArrayOrItem<NormalizedLinkDecoratorAutomaticDefinition>): void;
36
+ /**
37
+ * Provides the conversion helper used in the {@link module:engine/conversion/downcasthelpers~DowncastHelpers#add} method.
38
+ *
39
+ * @returns A dispatcher function used as conversion helper in {@link module:engine/conversion/downcasthelpers~DowncastHelpers#add}.
40
+ */
41
+ getDispatcher(): (dispatcher: DowncastDispatcher) => void;
42
+ /**
43
+ * Provides the conversion helper used in the {@link module:engine/conversion/downcasthelpers~DowncastHelpers#add} method
44
+ * when linking images.
45
+ *
46
+ * @returns A dispatcher function used as conversion helper in {@link module:engine/conversion/downcasthelpers~DowncastHelpers#add}.
47
+ */
48
+ getDispatcherForLinkedImage(): (dispatcher: DowncastDispatcher) => void;
49
+ }