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