@ckeditor/ckeditor5-link 44.3.0 → 45.0.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 (337) hide show
  1. package/LICENSE.md +1 -1
  2. package/build/link.js +2 -2
  3. package/build/translations/af.js +1 -1
  4. package/build/translations/ar.js +1 -1
  5. package/build/translations/ast.js +1 -1
  6. package/build/translations/az.js +1 -1
  7. package/build/translations/be.js +1 -0
  8. package/build/translations/bg.js +1 -1
  9. package/build/translations/bn.js +1 -1
  10. package/build/translations/bs.js +1 -1
  11. package/build/translations/ca.js +1 -1
  12. package/build/translations/cs.js +1 -1
  13. package/build/translations/da.js +1 -1
  14. package/build/translations/de-ch.js +1 -1
  15. package/build/translations/de.js +1 -1
  16. package/build/translations/el.js +1 -1
  17. package/build/translations/en-au.js +1 -1
  18. package/build/translations/en-gb.js +1 -1
  19. package/build/translations/eo.js +1 -1
  20. package/build/translations/es-co.js +1 -1
  21. package/build/translations/es.js +1 -1
  22. package/build/translations/et.js +1 -1
  23. package/build/translations/eu.js +1 -1
  24. package/build/translations/fa.js +1 -1
  25. package/build/translations/fi.js +1 -1
  26. package/build/translations/fr.js +1 -1
  27. package/build/translations/gl.js +1 -1
  28. package/build/translations/gu.js +1 -1
  29. package/build/translations/he.js +1 -1
  30. package/build/translations/hi.js +1 -1
  31. package/build/translations/hr.js +1 -1
  32. package/build/translations/hu.js +1 -1
  33. package/build/translations/hy.js +1 -1
  34. package/build/translations/id.js +1 -1
  35. package/build/translations/it.js +1 -1
  36. package/build/translations/ja.js +1 -1
  37. package/build/translations/jv.js +1 -1
  38. package/build/translations/kk.js +1 -1
  39. package/build/translations/km.js +1 -1
  40. package/build/translations/kn.js +1 -1
  41. package/build/translations/ko.js +1 -1
  42. package/build/translations/ku.js +1 -1
  43. package/build/translations/lt.js +1 -1
  44. package/build/translations/lv.js +1 -1
  45. package/build/translations/ms.js +1 -1
  46. package/build/translations/nb.js +1 -1
  47. package/build/translations/ne.js +1 -1
  48. package/build/translations/nl.js +1 -1
  49. package/build/translations/no.js +1 -1
  50. package/build/translations/oc.js +1 -1
  51. package/build/translations/pl.js +1 -1
  52. package/build/translations/pt-br.js +1 -1
  53. package/build/translations/pt.js +1 -1
  54. package/build/translations/ro.js +1 -1
  55. package/build/translations/ru.js +1 -1
  56. package/build/translations/si.js +1 -1
  57. package/build/translations/sk.js +1 -1
  58. package/build/translations/sl.js +1 -1
  59. package/build/translations/sq.js +1 -1
  60. package/build/translations/sr-latn.js +1 -1
  61. package/build/translations/sr.js +1 -1
  62. package/build/translations/sv.js +1 -1
  63. package/build/translations/th.js +1 -1
  64. package/build/translations/ti.js +1 -1
  65. package/build/translations/tk.js +1 -1
  66. package/build/translations/tr.js +1 -1
  67. package/build/translations/tt.js +1 -1
  68. package/build/translations/ug.js +1 -1
  69. package/build/translations/uk.js +1 -1
  70. package/build/translations/ur.js +1 -1
  71. package/build/translations/uz.js +1 -1
  72. package/build/translations/vi.js +1 -1
  73. package/build/translations/zh-cn.js +1 -1
  74. package/build/translations/zh.js +1 -1
  75. package/ckeditor5-metadata.json +2 -2
  76. package/dist/index-editor.css +87 -47
  77. package/dist/index.css +108 -58
  78. package/dist/index.css.map +1 -1
  79. package/dist/index.js +1161 -425
  80. package/dist/index.js.map +1 -1
  81. package/dist/translations/af.js +1 -1
  82. package/dist/translations/af.umd.js +1 -1
  83. package/dist/translations/ar.js +1 -1
  84. package/dist/translations/ar.umd.js +1 -1
  85. package/dist/translations/ast.js +1 -1
  86. package/dist/translations/ast.umd.js +1 -1
  87. package/dist/translations/az.js +1 -1
  88. package/dist/translations/az.umd.js +1 -1
  89. package/dist/translations/be.d.ts +8 -0
  90. package/dist/translations/be.js +5 -0
  91. package/dist/translations/be.umd.js +11 -0
  92. package/dist/translations/bg.js +1 -1
  93. package/dist/translations/bg.umd.js +1 -1
  94. package/dist/translations/bn.js +1 -1
  95. package/dist/translations/bn.umd.js +1 -1
  96. package/dist/translations/bs.js +1 -1
  97. package/dist/translations/bs.umd.js +1 -1
  98. package/dist/translations/ca.js +1 -1
  99. package/dist/translations/ca.umd.js +1 -1
  100. package/dist/translations/cs.js +1 -1
  101. package/dist/translations/cs.umd.js +1 -1
  102. package/dist/translations/da.js +1 -1
  103. package/dist/translations/da.umd.js +1 -1
  104. package/dist/translations/de-ch.js +1 -1
  105. package/dist/translations/de-ch.umd.js +1 -1
  106. package/dist/translations/de.js +1 -1
  107. package/dist/translations/de.umd.js +1 -1
  108. package/dist/translations/el.js +1 -1
  109. package/dist/translations/el.umd.js +1 -1
  110. package/dist/translations/en-au.js +1 -1
  111. package/dist/translations/en-au.umd.js +1 -1
  112. package/dist/translations/en-gb.js +1 -1
  113. package/dist/translations/en-gb.umd.js +1 -1
  114. package/dist/translations/en.js +1 -1
  115. package/dist/translations/en.umd.js +1 -1
  116. package/dist/translations/eo.js +1 -1
  117. package/dist/translations/eo.umd.js +1 -1
  118. package/dist/translations/es-co.js +1 -1
  119. package/dist/translations/es-co.umd.js +1 -1
  120. package/dist/translations/es.js +1 -1
  121. package/dist/translations/es.umd.js +1 -1
  122. package/dist/translations/et.js +1 -1
  123. package/dist/translations/et.umd.js +1 -1
  124. package/dist/translations/eu.js +1 -1
  125. package/dist/translations/eu.umd.js +1 -1
  126. package/dist/translations/fa.js +1 -1
  127. package/dist/translations/fa.umd.js +1 -1
  128. package/dist/translations/fi.js +1 -1
  129. package/dist/translations/fi.umd.js +1 -1
  130. package/dist/translations/fr.js +1 -1
  131. package/dist/translations/fr.umd.js +1 -1
  132. package/dist/translations/gl.js +1 -1
  133. package/dist/translations/gl.umd.js +1 -1
  134. package/dist/translations/gu.js +1 -1
  135. package/dist/translations/gu.umd.js +1 -1
  136. package/dist/translations/he.js +1 -1
  137. package/dist/translations/he.umd.js +1 -1
  138. package/dist/translations/hi.js +1 -1
  139. package/dist/translations/hi.umd.js +1 -1
  140. package/dist/translations/hr.js +1 -1
  141. package/dist/translations/hr.umd.js +1 -1
  142. package/dist/translations/hu.js +1 -1
  143. package/dist/translations/hu.umd.js +1 -1
  144. package/dist/translations/hy.js +1 -1
  145. package/dist/translations/hy.umd.js +1 -1
  146. package/dist/translations/id.js +1 -1
  147. package/dist/translations/id.umd.js +1 -1
  148. package/dist/translations/it.js +1 -1
  149. package/dist/translations/it.umd.js +1 -1
  150. package/dist/translations/ja.js +1 -1
  151. package/dist/translations/ja.umd.js +1 -1
  152. package/dist/translations/jv.js +1 -1
  153. package/dist/translations/jv.umd.js +1 -1
  154. package/dist/translations/kk.js +1 -1
  155. package/dist/translations/kk.umd.js +1 -1
  156. package/dist/translations/km.js +1 -1
  157. package/dist/translations/km.umd.js +1 -1
  158. package/dist/translations/kn.js +1 -1
  159. package/dist/translations/kn.umd.js +1 -1
  160. package/dist/translations/ko.js +1 -1
  161. package/dist/translations/ko.umd.js +1 -1
  162. package/dist/translations/ku.js +1 -1
  163. package/dist/translations/ku.umd.js +1 -1
  164. package/dist/translations/lt.js +1 -1
  165. package/dist/translations/lt.umd.js +1 -1
  166. package/dist/translations/lv.js +1 -1
  167. package/dist/translations/lv.umd.js +1 -1
  168. package/dist/translations/ms.js +1 -1
  169. package/dist/translations/ms.umd.js +1 -1
  170. package/dist/translations/nb.js +1 -1
  171. package/dist/translations/nb.umd.js +1 -1
  172. package/dist/translations/ne.js +1 -1
  173. package/dist/translations/ne.umd.js +1 -1
  174. package/dist/translations/nl.js +1 -1
  175. package/dist/translations/nl.umd.js +1 -1
  176. package/dist/translations/no.js +1 -1
  177. package/dist/translations/no.umd.js +1 -1
  178. package/dist/translations/oc.js +1 -1
  179. package/dist/translations/oc.umd.js +1 -1
  180. package/dist/translations/pl.js +1 -1
  181. package/dist/translations/pl.umd.js +1 -1
  182. package/dist/translations/pt-br.js +1 -1
  183. package/dist/translations/pt-br.umd.js +1 -1
  184. package/dist/translations/pt.js +1 -1
  185. package/dist/translations/pt.umd.js +1 -1
  186. package/dist/translations/ro.js +1 -1
  187. package/dist/translations/ro.umd.js +1 -1
  188. package/dist/translations/ru.js +1 -1
  189. package/dist/translations/ru.umd.js +1 -1
  190. package/dist/translations/si.js +1 -1
  191. package/dist/translations/si.umd.js +1 -1
  192. package/dist/translations/sk.js +1 -1
  193. package/dist/translations/sk.umd.js +1 -1
  194. package/dist/translations/sl.js +1 -1
  195. package/dist/translations/sl.umd.js +1 -1
  196. package/dist/translations/sq.js +1 -1
  197. package/dist/translations/sq.umd.js +1 -1
  198. package/dist/translations/sr-latn.js +1 -1
  199. package/dist/translations/sr-latn.umd.js +1 -1
  200. package/dist/translations/sr.js +1 -1
  201. package/dist/translations/sr.umd.js +1 -1
  202. package/dist/translations/sv.js +1 -1
  203. package/dist/translations/sv.umd.js +1 -1
  204. package/dist/translations/th.js +1 -1
  205. package/dist/translations/th.umd.js +1 -1
  206. package/dist/translations/ti.js +1 -1
  207. package/dist/translations/ti.umd.js +1 -1
  208. package/dist/translations/tk.js +1 -1
  209. package/dist/translations/tk.umd.js +1 -1
  210. package/dist/translations/tr.js +1 -1
  211. package/dist/translations/tr.umd.js +1 -1
  212. package/dist/translations/tt.js +1 -1
  213. package/dist/translations/tt.umd.js +1 -1
  214. package/dist/translations/ug.js +1 -1
  215. package/dist/translations/ug.umd.js +1 -1
  216. package/dist/translations/uk.js +1 -1
  217. package/dist/translations/uk.umd.js +1 -1
  218. package/dist/translations/ur.js +1 -1
  219. package/dist/translations/ur.umd.js +1 -1
  220. package/dist/translations/uz.js +1 -1
  221. package/dist/translations/uz.umd.js +1 -1
  222. package/dist/translations/vi.js +1 -1
  223. package/dist/translations/vi.umd.js +1 -1
  224. package/dist/translations/zh-cn.js +1 -1
  225. package/dist/translations/zh-cn.umd.js +1 -1
  226. package/dist/translations/zh.js +1 -1
  227. package/dist/translations/zh.umd.js +1 -1
  228. package/lang/contexts.json +4 -3
  229. package/lang/translations/af.po +10 -6
  230. package/lang/translations/ar.po +11 -7
  231. package/lang/translations/ast.po +10 -6
  232. package/lang/translations/az.po +10 -6
  233. package/lang/translations/be.po +68 -0
  234. package/lang/translations/bg.po +11 -7
  235. package/lang/translations/bn.po +11 -7
  236. package/lang/translations/bs.po +10 -6
  237. package/lang/translations/ca.po +11 -7
  238. package/lang/translations/cs.po +11 -7
  239. package/lang/translations/da.po +11 -7
  240. package/lang/translations/de-ch.po +10 -6
  241. package/lang/translations/de.po +11 -7
  242. package/lang/translations/el.po +11 -7
  243. package/lang/translations/en-au.po +11 -7
  244. package/lang/translations/en-gb.po +11 -7
  245. package/lang/translations/en.po +11 -7
  246. package/lang/translations/eo.po +10 -6
  247. package/lang/translations/es-co.po +10 -6
  248. package/lang/translations/es.po +11 -7
  249. package/lang/translations/et.po +11 -7
  250. package/lang/translations/eu.po +10 -6
  251. package/lang/translations/fa.po +10 -6
  252. package/lang/translations/fi.po +11 -7
  253. package/lang/translations/fr.po +11 -7
  254. package/lang/translations/gl.po +10 -6
  255. package/lang/translations/gu.po +10 -6
  256. package/lang/translations/he.po +11 -7
  257. package/lang/translations/hi.po +11 -7
  258. package/lang/translations/hr.po +10 -6
  259. package/lang/translations/hu.po +11 -7
  260. package/lang/translations/hy.po +10 -6
  261. package/lang/translations/id.po +11 -7
  262. package/lang/translations/it.po +11 -7
  263. package/lang/translations/ja.po +11 -7
  264. package/lang/translations/jv.po +10 -6
  265. package/lang/translations/kk.po +10 -6
  266. package/lang/translations/km.po +10 -6
  267. package/lang/translations/kn.po +10 -6
  268. package/lang/translations/ko.po +11 -7
  269. package/lang/translations/ku.po +10 -6
  270. package/lang/translations/lt.po +11 -7
  271. package/lang/translations/lv.po +11 -7
  272. package/lang/translations/ms.po +11 -7
  273. package/lang/translations/nb.po +10 -6
  274. package/lang/translations/ne.po +10 -6
  275. package/lang/translations/nl.po +11 -7
  276. package/lang/translations/no.po +11 -7
  277. package/lang/translations/oc.po +10 -6
  278. package/lang/translations/pl.po +11 -7
  279. package/lang/translations/pt-br.po +11 -7
  280. package/lang/translations/pt.po +11 -7
  281. package/lang/translations/ro.po +11 -7
  282. package/lang/translations/ru.po +11 -7
  283. package/lang/translations/si.po +10 -6
  284. package/lang/translations/sk.po +11 -7
  285. package/lang/translations/sl.po +10 -6
  286. package/lang/translations/sq.po +10 -6
  287. package/lang/translations/sr-latn.po +10 -6
  288. package/lang/translations/sr.po +11 -7
  289. package/lang/translations/sv.po +11 -7
  290. package/lang/translations/th.po +11 -7
  291. package/lang/translations/ti.po +10 -6
  292. package/lang/translations/tk.po +10 -6
  293. package/lang/translations/tr.po +11 -7
  294. package/lang/translations/tt.po +10 -6
  295. package/lang/translations/ug.po +10 -6
  296. package/lang/translations/uk.po +11 -7
  297. package/lang/translations/ur.po +10 -6
  298. package/lang/translations/uz.po +10 -6
  299. package/lang/translations/vi.po +11 -7
  300. package/lang/translations/zh-cn.po +11 -7
  301. package/lang/translations/zh.po +11 -7
  302. package/package.json +12 -12
  303. package/src/autolink.js +3 -0
  304. package/src/index.d.ts +1 -2
  305. package/src/index.js +0 -1
  306. package/src/linkcommand.d.ts +17 -10
  307. package/src/linkcommand.js +212 -82
  308. package/src/linkconfig.d.ts +28 -0
  309. package/src/linkediting.d.ts +18 -0
  310. package/src/linkediting.js +19 -9
  311. package/src/linkimageui.d.ts +1 -1
  312. package/src/linkimageui.js +4 -4
  313. package/src/linkui.d.ts +215 -24
  314. package/src/linkui.js +517 -109
  315. package/src/ui/linkbuttonview.d.ts +31 -0
  316. package/src/ui/linkbuttonview.js +54 -0
  317. package/src/ui/linkformview.d.ts +34 -49
  318. package/src/ui/linkformview.js +163 -134
  319. package/src/ui/linkpreviewbuttonview.d.ts +35 -0
  320. package/src/ui/linkpreviewbuttonview.js +43 -0
  321. package/src/ui/linkpropertiesview.d.ts +88 -0
  322. package/src/ui/linkpropertiesview.js +170 -0
  323. package/src/ui/linkprovideritemsview.d.ts +114 -0
  324. package/src/ui/linkprovideritemsview.js +207 -0
  325. package/src/utils/automaticdecorators.js +5 -7
  326. package/src/utils/manualdecorator.js +27 -0
  327. package/src/utils.d.ts +5 -5
  328. package/src/utils.js +12 -32
  329. package/theme/linkform.css +11 -33
  330. package/theme/linkproperties.css +4 -0
  331. package/theme/linkprovideritems.css +18 -0
  332. package/theme/linktoolbar.css +12 -0
  333. package/src/ui/linkactionsview.d.ts +0 -117
  334. package/src/ui/linkactionsview.js +0 -173
  335. package/theme/icons/link.svg +0 -1
  336. package/theme/icons/unlink.svg +0 -1
  337. package/theme/linkactions.css +0 -32
@@ -0,0 +1,31 @@
1
+ /**
2
+ * @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
3
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
4
+ */
5
+ import { ButtonView, IconView } from 'ckeditor5/src/ui.js';
6
+ import type { Locale } from 'ckeditor5/src/utils.js';
7
+ /**
8
+ * Represents a view for a dropdown menu button.
9
+ */
10
+ export default class LinkButtonView extends ButtonView {
11
+ /**
12
+ * An icon that displays an arrow to indicate a direction of the menu.
13
+ */
14
+ readonly arrowView: IconView;
15
+ /**
16
+ * Creates an instance of the dropdown menu button view.
17
+ *
18
+ * @param locale The localization services instance.
19
+ */
20
+ constructor(locale?: Locale);
21
+ /**
22
+ * @inheritDoc
23
+ */
24
+ render(): void;
25
+ /**
26
+ * Creates the arrow view instance.
27
+ *
28
+ * @private
29
+ */
30
+ private _createArrowView;
31
+ }
@@ -0,0 +1,54 @@
1
+ /**
2
+ * @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
3
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
4
+ */
5
+ /**
6
+ * @module link/ui/linkbuttonview
7
+ */
8
+ import { IconNextArrow } from '@ckeditor/ckeditor5-icons';
9
+ import { ButtonView, IconView } from 'ckeditor5/src/ui.js';
10
+ /**
11
+ * Represents a view for a dropdown menu button.
12
+ */
13
+ export default class LinkButtonView extends ButtonView {
14
+ /**
15
+ * An icon that displays an arrow to indicate a direction of the menu.
16
+ */
17
+ arrowView;
18
+ /**
19
+ * Creates an instance of the dropdown menu button view.
20
+ *
21
+ * @param locale The localization services instance.
22
+ */
23
+ constructor(locale) {
24
+ super(locale);
25
+ this.set({
26
+ withText: true
27
+ });
28
+ this.arrowView = this._createArrowView();
29
+ this.extendTemplate({
30
+ attributes: {
31
+ class: [
32
+ 'ck-link__button'
33
+ ]
34
+ }
35
+ });
36
+ }
37
+ /**
38
+ * @inheritDoc
39
+ */
40
+ render() {
41
+ super.render();
42
+ this.children.add(this.arrowView);
43
+ }
44
+ /**
45
+ * Creates the arrow view instance.
46
+ *
47
+ * @private
48
+ */
49
+ _createArrowView() {
50
+ const arrowView = new IconView();
51
+ arrowView.content = IconNextArrow;
52
+ return arrowView;
53
+ }
54
+ }
@@ -7,13 +7,11 @@
7
7
  */
8
8
  import { ButtonView, LabeledFieldView, View, ViewCollection, type InputTextView } from 'ckeditor5/src/ui.js';
9
9
  import { FocusTracker, KeystrokeHandler, type Locale } from 'ckeditor5/src/utils.js';
10
- import type LinkCommand from '../linkcommand.js';
11
10
  import '@ckeditor/ckeditor5-ui/theme/components/responsive-form/responsiveform.css';
11
+ import '@ckeditor/ckeditor5-ui/theme/components/form/form.css';
12
12
  import '../../theme/linkform.css';
13
13
  /**
14
- * The link form view controller class.
15
- *
16
- * See {@link module:link/ui/linkformview~LinkFormView}.
14
+ * The link form view.
17
15
  */
18
16
  export default class LinkFormView extends View {
19
17
  /**
@@ -25,27 +23,29 @@ export default class LinkFormView extends View {
25
23
  */
26
24
  readonly keystrokes: KeystrokeHandler;
27
25
  /**
28
- * The URL input view.
26
+ * The Back button view displayed in the header.
29
27
  */
30
- urlInputView: LabeledFieldView<InputTextView>;
28
+ backButtonView: ButtonView;
31
29
  /**
32
30
  * The Save button view.
33
31
  */
34
32
  saveButtonView: ButtonView;
35
33
  /**
36
- * The Cancel button view.
34
+ * The "Displayed text" input view.
37
35
  */
38
- cancelButtonView: ButtonView;
36
+ displayedTextInputView: LabeledFieldView<InputTextView>;
39
37
  /**
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.
38
+ * The URL input view.
43
39
  */
44
- private readonly _manualDecoratorSwitches;
40
+ urlInputView: LabeledFieldView<InputTextView>;
45
41
  /**
46
- * A collection of child views in the form.
42
+ * A collection of child views.
47
43
  */
48
44
  readonly children: ViewCollection;
45
+ /**
46
+ * A collection of child views in the providers list.
47
+ */
48
+ readonly providersListChildren: ViewCollection<ButtonView>;
49
49
  /**
50
50
  * An array of form validators used by {@link #isValid}.
51
51
  */
@@ -64,18 +64,9 @@ export default class LinkFormView extends View {
64
64
  * Also see {@link #render}.
65
65
  *
66
66
  * @param locale The localization services instance.
67
- * @param linkCommand Reference to {@link module:link/linkcommand~LinkCommand}.
68
67
  * @param validators Form validators used by {@link #isValid}.
69
68
  */
70
- constructor(locale: Locale, linkCommand: LinkCommand, validators: Array<LinkFormValidatorCallback>);
71
- /**
72
- * Obtains the state of the {@link module:ui/button/switchbuttonview~SwitchButtonView switch buttons} representing
73
- * {@link module:link/linkcommand~LinkCommand#manualDecorators manual link decorators}
74
- * in the {@link module:link/ui/linkformview~LinkFormView}.
75
- *
76
- * @returns Key-value pairs, where the key is the name of the decorator and the value is its state.
77
- */
78
- getDecoratorSwitchesState(): Record<string, boolean>;
69
+ constructor(locale: Locale, validators: Array<LinkFormValidatorCallback>);
79
70
  /**
80
71
  * @inheritDoc
81
72
  */
@@ -100,39 +91,33 @@ export default class LinkFormView extends View {
100
91
  */
101
92
  resetFormStatus(): void;
102
93
  /**
103
- * Creates a labeled input view.
104
- *
105
- * @returns Labeled field view instance.
94
+ * Creates a back button view that cancels the form.
106
95
  */
107
- private _createUrlInput;
96
+ private _createBackButton;
108
97
  /**
109
- * Creates a button view.
110
- *
111
- * @param label The button label.
112
- * @param icon The button icon.
113
- * @param className The additional button CSS class name.
114
- * @param eventName An event name that the `ButtonView#execute` event will be delegated to.
115
- * @returns The button view instance.
98
+ * Creates a save button view that inserts the link.
99
+ */
100
+ private _createSaveButton;
101
+ /**
102
+ * Creates a header view for the form.
103
+ */
104
+ private _createHeaderView;
105
+ /**
106
+ * Creates a view for the providers list.
116
107
  */
117
- private _createButton;
108
+ private _createProvidersListView;
118
109
  /**
119
- * Populates {@link module:ui/viewcollection~ViewCollection} of {@link module:ui/button/switchbuttonview~SwitchButtonView}
120
- * made based on {@link module:link/linkcommand~LinkCommand#manualDecorators}.
110
+ * Creates a labeled input view for the "Displayed text" field.
111
+ */
112
+ private _createDisplayedTextInput;
113
+ /**
114
+ * Creates a labeled input view for the URL field.
121
115
  *
122
- * @param linkCommand A reference to the link command.
123
- * @returns ViewCollection of switch buttons.
116
+ * @returns Labeled field view instance.
124
117
  */
125
- private _createManualDecoratorSwitches;
118
+ private _createUrlInput;
126
119
  /**
127
120
  * Populates the {@link #children} collection of the form.
128
- *
129
- * If {@link module:link/linkcommand~LinkCommand#manualDecorators manual decorators} are configured in the editor, it creates an
130
- * additional `View` wrapping all {@link #_manualDecoratorSwitches} switch buttons corresponding
131
- * to these decorators.
132
- *
133
- * @param manualDecorators A reference to
134
- * the collection of manual decorators stored in the link command.
135
- * @returns The children of link form view.
136
121
  */
137
122
  private _createFormChildren;
138
123
  /**
@@ -161,7 +146,7 @@ export type SubmitEvent = {
161
146
  args: [];
162
147
  };
163
148
  /**
164
- * Fired when the form view is canceled, for example with a click on {@link ~LinkFormView#cancelButtonView}.
149
+ * Fired when the form view is canceled, for example with a click on {@link ~LinkFormView#backButtonView}.
165
150
  *
166
151
  * @eventName ~LinkFormView#cancel
167
152
  */
@@ -5,50 +5,91 @@
5
5
  /**
6
6
  * @module link/ui/linkformview
7
7
  */
8
- import { ButtonView, FocusCycler, LabeledFieldView, SwitchButtonView, View, ViewCollection, createLabeledInputText, submitHandler } from 'ckeditor5/src/ui.js';
8
+ import { ButtonView, ListView, ListItemView, FocusCycler, LabeledFieldView, FormHeaderView, FormRowView, View, ViewCollection, createLabeledInputText, submitHandler } from 'ckeditor5/src/ui.js';
9
9
  import { FocusTracker, KeystrokeHandler } from 'ckeditor5/src/utils.js';
10
- import { icons } from 'ckeditor5/src/core.js';
10
+ import { IconPreviousArrow } from 'ckeditor5/src/icons.js';
11
11
  // See: #8833.
12
12
  // eslint-disable-next-line ckeditor5-rules/ckeditor-imports
13
13
  import '@ckeditor/ckeditor5-ui/theme/components/responsive-form/responsiveform.css';
14
+ // eslint-disable-next-line ckeditor5-rules/ckeditor-imports
15
+ import '@ckeditor/ckeditor5-ui/theme/components/form/form.css';
14
16
  import '../../theme/linkform.css';
15
17
  /**
16
- * The link form view controller class.
17
- *
18
- * See {@link module:link/ui/linkformview~LinkFormView}.
18
+ * The link form view.
19
19
  */
20
20
  export default class LinkFormView extends View {
21
+ /**
22
+ * Tracks information about DOM focus in the form.
23
+ */
24
+ focusTracker = new FocusTracker();
25
+ /**
26
+ * An instance of the {@link module:utils/keystrokehandler~KeystrokeHandler}.
27
+ */
28
+ keystrokes = new KeystrokeHandler();
29
+ /**
30
+ * The Back button view displayed in the header.
31
+ */
32
+ backButtonView;
33
+ /**
34
+ * The Save button view.
35
+ */
36
+ saveButtonView;
37
+ /**
38
+ * The "Displayed text" input view.
39
+ */
40
+ displayedTextInputView;
41
+ /**
42
+ * The URL input view.
43
+ */
44
+ urlInputView;
45
+ /**
46
+ * A collection of child views.
47
+ */
48
+ children;
49
+ /**
50
+ * A collection of child views in the providers list.
51
+ */
52
+ providersListChildren;
53
+ /**
54
+ * An array of form validators used by {@link #isValid}.
55
+ */
56
+ _validators;
57
+ /**
58
+ * A collection of views that can be focused in the form.
59
+ */
60
+ _focusables = new ViewCollection();
61
+ /**
62
+ * Helps cycling over {@link #_focusables} in the form.
63
+ */
64
+ _focusCycler;
21
65
  /**
22
66
  * Creates an instance of the {@link module:link/ui/linkformview~LinkFormView} class.
23
67
  *
24
68
  * Also see {@link #render}.
25
69
  *
26
70
  * @param locale The localization services instance.
27
- * @param linkCommand Reference to {@link module:link/linkcommand~LinkCommand}.
28
71
  * @param validators Form validators used by {@link #isValid}.
29
72
  */
30
- constructor(locale, linkCommand, validators) {
73
+ constructor(locale, validators) {
31
74
  super(locale);
32
- /**
33
- * Tracks information about DOM focus in the form.
34
- */
35
- this.focusTracker = new FocusTracker();
36
- /**
37
- * An instance of the {@link module:utils/keystrokehandler~KeystrokeHandler}.
38
- */
39
- this.keystrokes = new KeystrokeHandler();
40
- /**
41
- * A collection of views that can be focused in the form.
42
- */
43
- this._focusables = new ViewCollection();
44
- const t = locale.t;
45
75
  this._validators = validators;
76
+ // Create buttons.
77
+ this.backButtonView = this._createBackButton();
78
+ this.saveButtonView = this._createSaveButton();
79
+ // Create input fields.
80
+ this.displayedTextInputView = this._createDisplayedTextInput();
46
81
  this.urlInputView = this._createUrlInput();
47
- this.saveButtonView = this._createButton(t('Save'), icons.check, 'ck-button-save');
48
- this.saveButtonView.type = 'submit';
49
- this.cancelButtonView = this._createButton(t('Cancel'), icons.cancel, 'ck-button-cancel', 'cancel');
50
- this._manualDecoratorSwitches = this._createManualDecoratorSwitches(linkCommand);
51
- this.children = this._createFormChildren(linkCommand.manualDecorators);
82
+ this.providersListChildren = this.createCollection();
83
+ this.children = this.createCollection([
84
+ this._createHeaderView()
85
+ ]);
86
+ this._createFormChildren();
87
+ // Add providers list view to the children when the first item is added to the list.
88
+ // This is to avoid adding the list view when the form is empty.
89
+ this.listenTo(this.providersListChildren, 'add', () => {
90
+ this.stopListening(this.providersListChildren, 'add');
91
+ this.children.add(this._createProvidersListView());
92
+ });
52
93
  this._focusCycler = new FocusCycler({
53
94
  focusables: this._focusables,
54
95
  focusTracker: this.focusTracker,
@@ -60,35 +101,21 @@ export default class LinkFormView extends View {
60
101
  focusNext: 'tab'
61
102
  }
62
103
  });
63
- const classList = ['ck', 'ck-link-form', 'ck-responsive-form'];
64
- if (linkCommand.manualDecorators.length) {
65
- classList.push('ck-link-form_layout-vertical', 'ck-vertical-form');
66
- }
67
104
  this.setTemplate({
68
105
  tag: 'form',
69
106
  attributes: {
70
- class: classList,
107
+ class: [
108
+ 'ck',
109
+ 'ck-form',
110
+ 'ck-link-form',
111
+ 'ck-responsive-form'
112
+ ],
71
113
  // https://github.com/ckeditor/ckeditor5-link/issues/90
72
114
  tabindex: '-1'
73
115
  },
74
116
  children: this.children
75
117
  });
76
118
  }
77
- /**
78
- * Obtains the state of the {@link module:ui/button/switchbuttonview~SwitchButtonView switch buttons} representing
79
- * {@link module:link/linkcommand~LinkCommand#manualDecorators manual link decorators}
80
- * in the {@link module:link/ui/linkformview~LinkFormView}.
81
- *
82
- * @returns Key-value pairs, where the key is the name of the decorator and the value is its state.
83
- */
84
- getDecoratorSwitchesState() {
85
- return Array
86
- .from(this._manualDecoratorSwitches)
87
- .reduce((accumulator, switchButton) => {
88
- accumulator[switchButton.name] = switchButton.isOn;
89
- return accumulator;
90
- }, {});
91
- }
92
119
  /**
93
120
  * @inheritDoc
94
121
  */
@@ -99,9 +126,10 @@ export default class LinkFormView extends View {
99
126
  });
100
127
  const childViews = [
101
128
  this.urlInputView,
102
- ...this._manualDecoratorSwitches,
103
129
  this.saveButtonView,
104
- this.cancelButtonView
130
+ ...this.providersListChildren,
131
+ this.backButtonView,
132
+ this.displayedTextInputView
105
133
  ];
106
134
  childViews.forEach(v => {
107
135
  // Register the view as focusable.
@@ -152,110 +180,111 @@ export default class LinkFormView extends View {
152
180
  this.urlInputView.errorText = null;
153
181
  }
154
182
  /**
155
- * Creates a labeled input view.
156
- *
157
- * @returns Labeled field view instance.
183
+ * Creates a back button view that cancels the form.
158
184
  */
159
- _createUrlInput() {
185
+ _createBackButton() {
160
186
  const t = this.locale.t;
161
- const labeledInput = new LabeledFieldView(this.locale, createLabeledInputText);
162
- labeledInput.fieldView.inputMode = 'url';
163
- labeledInput.label = t('Link URL');
164
- return labeledInput;
187
+ const backButton = new ButtonView(this.locale);
188
+ backButton.set({
189
+ class: 'ck-button-back',
190
+ label: t('Back'),
191
+ icon: IconPreviousArrow,
192
+ tooltip: true
193
+ });
194
+ backButton.delegate('execute').to(this, 'cancel');
195
+ return backButton;
165
196
  }
166
197
  /**
167
- * Creates a button view.
168
- *
169
- * @param label The button label.
170
- * @param icon The button icon.
171
- * @param className The additional button CSS class name.
172
- * @param eventName An event name that the `ButtonView#execute` event will be delegated to.
173
- * @returns The button view instance.
198
+ * Creates a save button view that inserts the link.
174
199
  */
175
- _createButton(label, icon, className, eventName) {
176
- const button = new ButtonView(this.locale);
177
- button.set({
178
- label,
179
- icon,
180
- tooltip: true
200
+ _createSaveButton() {
201
+ const t = this.locale.t;
202
+ const saveButton = new ButtonView(this.locale);
203
+ saveButton.set({
204
+ label: t('Insert'),
205
+ tooltip: false,
206
+ withText: true,
207
+ type: 'submit',
208
+ class: 'ck-button-action ck-button-bold'
181
209
  });
182
- button.extendTemplate({
210
+ return saveButton;
211
+ }
212
+ /**
213
+ * Creates a header view for the form.
214
+ */
215
+ _createHeaderView() {
216
+ const t = this.locale.t;
217
+ const header = new FormHeaderView(this.locale, {
218
+ label: t('Link')
219
+ });
220
+ header.children.add(this.backButtonView, 0);
221
+ return header;
222
+ }
223
+ /**
224
+ * Creates a view for the providers list.
225
+ */
226
+ _createProvidersListView() {
227
+ const providersListView = new ListView(this.locale);
228
+ providersListView.extendTemplate({
183
229
  attributes: {
184
- class: className
230
+ class: [
231
+ 'ck-link-form__providers-list'
232
+ ]
185
233
  }
186
234
  });
187
- if (eventName) {
188
- button.delegate('execute').to(this, eventName);
189
- }
190
- return button;
235
+ providersListView.items.bindTo(this.providersListChildren).using(def => {
236
+ const listItemView = new ListItemView(this.locale);
237
+ listItemView.children.add(def);
238
+ return listItemView;
239
+ });
240
+ return providersListView;
191
241
  }
192
242
  /**
193
- * Populates {@link module:ui/viewcollection~ViewCollection} of {@link module:ui/button/switchbuttonview~SwitchButtonView}
194
- * made based on {@link module:link/linkcommand~LinkCommand#manualDecorators}.
243
+ * Creates a labeled input view for the "Displayed text" field.
244
+ */
245
+ _createDisplayedTextInput() {
246
+ const t = this.locale.t;
247
+ const labeledInput = new LabeledFieldView(this.locale, createLabeledInputText);
248
+ labeledInput.label = t('Displayed text');
249
+ labeledInput.class = 'ck-labeled-field-view_full-width';
250
+ return labeledInput;
251
+ }
252
+ /**
253
+ * Creates a labeled input view for the URL field.
195
254
  *
196
- * @param linkCommand A reference to the link command.
197
- * @returns ViewCollection of switch buttons.
255
+ * @returns Labeled field view instance.
198
256
  */
199
- _createManualDecoratorSwitches(linkCommand) {
200
- const switches = this.createCollection();
201
- for (const manualDecorator of linkCommand.manualDecorators) {
202
- const switchButton = new SwitchButtonView(this.locale);
203
- switchButton.set({
204
- name: manualDecorator.id,
205
- label: manualDecorator.label,
206
- withText: true
207
- });
208
- switchButton.bind('isOn').toMany([manualDecorator, linkCommand], 'value', (decoratorValue, commandValue) => {
209
- return commandValue === undefined && decoratorValue === undefined ? !!manualDecorator.defaultValue : !!decoratorValue;
210
- });
211
- switchButton.on('execute', () => {
212
- manualDecorator.set('value', !switchButton.isOn);
213
- });
214
- switches.add(switchButton);
215
- }
216
- return switches;
257
+ _createUrlInput() {
258
+ const t = this.locale.t;
259
+ const labeledInput = new LabeledFieldView(this.locale, createLabeledInputText);
260
+ labeledInput.fieldView.inputMode = 'url';
261
+ labeledInput.label = t('Link URL');
262
+ labeledInput.class = 'ck-labeled-field-view_full-width';
263
+ return labeledInput;
217
264
  }
218
265
  /**
219
266
  * Populates the {@link #children} collection of the form.
220
- *
221
- * If {@link module:link/linkcommand~LinkCommand#manualDecorators manual decorators} are configured in the editor, it creates an
222
- * additional `View` wrapping all {@link #_manualDecoratorSwitches} switch buttons corresponding
223
- * to these decorators.
224
- *
225
- * @param manualDecorators A reference to
226
- * the collection of manual decorators stored in the link command.
227
- * @returns The children of link form view.
228
267
  */
229
- _createFormChildren(manualDecorators) {
230
- const children = this.createCollection();
231
- children.add(this.urlInputView);
232
- if (manualDecorators.length) {
233
- const additionalButtonsView = new View();
234
- additionalButtonsView.setTemplate({
235
- tag: 'ul',
236
- children: this._manualDecoratorSwitches.map(switchButton => ({
237
- tag: 'li',
238
- children: [switchButton],
239
- attributes: {
240
- class: [
241
- 'ck',
242
- 'ck-list__item'
243
- ]
244
- }
245
- })),
246
- attributes: {
247
- class: [
248
- 'ck',
249
- 'ck-reset',
250
- 'ck-list'
251
- ]
252
- }
253
- });
254
- children.add(additionalButtonsView);
255
- }
256
- children.add(this.saveButtonView);
257
- children.add(this.cancelButtonView);
258
- return children;
268
+ _createFormChildren() {
269
+ this.children.add(new FormRowView(this.locale, {
270
+ children: [
271
+ this.displayedTextInputView
272
+ ],
273
+ class: [
274
+ 'ck-form__row_large-top-padding'
275
+ ]
276
+ }));
277
+ this.children.add(new FormRowView(this.locale, {
278
+ children: [
279
+ this.urlInputView,
280
+ this.saveButtonView
281
+ ],
282
+ class: [
283
+ 'ck-form__row_with-submit',
284
+ 'ck-form__row_large-top-padding',
285
+ 'ck-form__row_large-bottom-padding'
286
+ ]
287
+ }));
259
288
  }
260
289
  /**
261
290
  * The native DOM `value` of the {@link #urlInputView} element.
@@ -0,0 +1,35 @@
1
+ /**
2
+ * @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
3
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
4
+ */
5
+ /**
6
+ * @module link/ui/linkpreviewbuttonview
7
+ */
8
+ import { ButtonView } from 'ckeditor5/src/ui.js';
9
+ import type { Locale } from 'ckeditor5/src/utils.js';
10
+ /**
11
+ * The link button class. Rendered as an `<a>` tag with link opening in a new tab.
12
+ *
13
+ * Provides a custom `navigate` cancelable event.
14
+ */
15
+ export default class LinkPreviewButtonView extends ButtonView {
16
+ /**
17
+ * The value of the "href" attribute of the link.
18
+ *
19
+ * @observable
20
+ */
21
+ href: string | undefined;
22
+ /**
23
+ * @inheritDoc
24
+ */
25
+ constructor(locale: Locale);
26
+ }
27
+ /**
28
+ * Fired when the button view is clicked.
29
+ *
30
+ * @eventName ~LinkPreviewButtonView#navigate
31
+ */
32
+ export type LinkPreviewButtonNavigateEvent = {
33
+ name: 'navigate';
34
+ args: [href: string, cancel: () => void];
35
+ };
@@ -0,0 +1,43 @@
1
+ /**
2
+ * @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
3
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
4
+ */
5
+ /**
6
+ * @module link/ui/linkpreviewbuttonview
7
+ */
8
+ import { ButtonView } from 'ckeditor5/src/ui.js';
9
+ /**
10
+ * The link button class. Rendered as an `<a>` tag with link opening in a new tab.
11
+ *
12
+ * Provides a custom `navigate` cancelable event.
13
+ */
14
+ export default class LinkPreviewButtonView extends ButtonView {
15
+ /**
16
+ * @inheritDoc
17
+ */
18
+ constructor(locale) {
19
+ super(locale);
20
+ const bind = this.bindTemplate;
21
+ this.set({
22
+ href: undefined,
23
+ withText: true
24
+ });
25
+ this.extendTemplate({
26
+ attributes: {
27
+ class: ['ck-link-toolbar__preview'],
28
+ href: bind.to('href'),
29
+ target: '_blank',
30
+ rel: 'noopener noreferrer'
31
+ },
32
+ on: {
33
+ click: bind.to(evt => {
34
+ if (this.href) {
35
+ const cancel = () => evt.preventDefault();
36
+ this.fire('navigate', this.href, cancel);
37
+ }
38
+ })
39
+ }
40
+ });
41
+ this.template.tag = 'a';
42
+ }
43
+ }