@ckeditor/ckeditor5-link 44.3.0-alpha.7 → 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
package/src/utils.js CHANGED
@@ -2,7 +2,7 @@
2
2
  * @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
3
3
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
4
4
  */
5
- import { upperFirst } from 'lodash-es';
5
+ import { upperFirst } from 'es-toolkit/compat';
6
6
  const ATTRIBUTE_WHITESPACES = /[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205f\u3000]/g; // eslint-disable-line no-control-regex
7
7
  const SAFE_URL_TEMPLATE = '^(?:(?:<protocols>):|[^a-z]|[a-z+.-]+(?:[^a-z+.:-]|$))';
8
8
  // Simplified email test - should be run over previously found URL.
@@ -134,37 +134,17 @@ export function openLink(link) {
134
134
  window.open(link, '_blank', 'noopener');
135
135
  }
136
136
  /**
137
- * Creates the bookmark callbacks for handling link opening experience.
137
+ * Returns a text of a link range.
138
+ *
139
+ * If the returned value is `undefined`, the range contains elements other than text nodes.
138
140
  */
139
- export function createBookmarkCallbacks(editor) {
140
- const bookmarkEditing = editor.plugins.has('BookmarkEditing') ?
141
- editor.plugins.get('BookmarkEditing') :
142
- null;
143
- /**
144
- * Returns `true` when bookmark `id` matches the hash from `link`.
145
- */
146
- function isScrollableToTarget(link) {
147
- return !!link &&
148
- link.startsWith('#') &&
149
- !!bookmarkEditing &&
150
- !!bookmarkEditing.getElementForBookmarkId(link.slice(1));
151
- }
152
- /**
153
- * Scrolls the view to the desired bookmark or open a link in new window.
154
- */
155
- function scrollToTarget(link) {
156
- const bookmarkId = link.slice(1);
157
- const modelBookmark = bookmarkEditing.getElementForBookmarkId(bookmarkId);
158
- editor.model.change(writer => {
159
- writer.setSelection(modelBookmark, 'on');
160
- });
161
- editor.editing.view.scrollToTheSelection({
162
- alignToTop: true,
163
- forceScroll: true
164
- });
141
+ export function extractTextFromLinkRange(range) {
142
+ let text = '';
143
+ for (const item of range.getItems()) {
144
+ if (!item.is('$text') && !item.is('$textProxy')) {
145
+ return;
146
+ }
147
+ text += item.data;
165
148
  }
166
- return {
167
- isScrollableToTarget,
168
- scrollToTarget
169
- };
149
+ return text;
170
150
  }
@@ -5,42 +5,20 @@
5
5
 
6
6
  @import "@ckeditor/ckeditor5-ui/theme/mixins/_rwd.css";
7
7
 
8
+ /* Generic class that wraps each link balloon view. */
8
9
  .ck.ck-link-form {
9
- display: flex;
10
- align-items: flex-start;
11
-
12
- & .ck-label {
13
- display: none;
14
- }
15
-
16
- @mixin ck-media-phone {
17
- flex-wrap: wrap;
18
-
19
- & .ck-labeled-field-view {
20
- flex-basis: 100%;
21
- }
22
-
23
- & .ck-button {
24
- flex-basis: 50%;
10
+ & .ck-link-form__providers-list {
11
+ display: flex;
12
+ flex-direction: column;
13
+
14
+ & .ck-link__button {
15
+ & > .ck-button__label {
16
+ flex-grow: 1;
17
+ }
25
18
  }
26
19
  }
27
- }
28
-
29
- /*
30
- * Style link form differently when manual decorators are available.
31
- * See: https://github.com/ckeditor/ckeditor5-link/issues/186.
32
- */
33
- .ck.ck-link-form_layout-vertical {
34
- display: block;
35
20
 
36
- /*
37
- * Whether the form is in the responsive mode or not, if there are decorator buttons
38
- * keep the top margin of action buttons medium.
39
- */
40
- & .ck-button {
41
- &.ck-button-save,
42
- &.ck-button-cancel {
43
- margin-top: var(--ck-spacing-medium);
44
- }
21
+ & .ck-link__items:empty {
22
+ display: none;
45
23
  }
46
24
  }
@@ -0,0 +1,4 @@
1
+ /*
2
+ * 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
+ */
@@ -0,0 +1,18 @@
1
+ /*
2
+ * 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
+ .ck.ck-link-providers {
7
+ & > .ck-link-providers__list {
8
+ overflow-x: hidden;
9
+ overflow-y: auto;
10
+ overscroll-behavior: contain;
11
+
12
+ & .ck-button {
13
+ & > .ck-icon {
14
+ flex-shrink: 0;
15
+ }
16
+ }
17
+ }
18
+ }
@@ -0,0 +1,12 @@
1
+ /*
2
+ * 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
+ .ck.ck-link-toolbar__preview {
7
+ display: inline-block;
8
+
9
+ & .ck-button__label {
10
+ overflow: hidden;
11
+ }
12
+ }
@@ -1,117 +0,0 @@
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/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
- private readonly _options?;
54
- t: LocaleTranslate;
55
- /**
56
- * @inheritDoc
57
- */
58
- constructor(locale: Locale, linkConfig?: LinkConfig, options?: LinkActionsViewOptions);
59
- /**
60
- * @inheritDoc
61
- */
62
- render(): void;
63
- /**
64
- * @inheritDoc
65
- */
66
- destroy(): void;
67
- /**
68
- * Focuses the fist {@link #_focusables} in the actions.
69
- */
70
- focus(): void;
71
- /**
72
- * Creates a button view.
73
- *
74
- * @param label The button label.
75
- * @param icon The button icon.
76
- * @param eventName An event name that the `ButtonView#execute` event will be delegated to.
77
- * @returns The button view instance.
78
- */
79
- private _createButton;
80
- /**
81
- * Creates a link href preview button.
82
- *
83
- * @returns The button view instance.
84
- */
85
- private _createPreviewButton;
86
- }
87
- /**
88
- * Fired when the {@link ~LinkActionsView#editButtonView} is clicked.
89
- *
90
- * @eventName ~LinkActionsView#edit
91
- */
92
- export type EditEvent = {
93
- name: 'edit';
94
- args: [];
95
- };
96
- /**
97
- * Fired when the {@link ~LinkActionsView#unlinkButtonView} is clicked.
98
- *
99
- * @eventName ~LinkActionsView#unlink
100
- */
101
- export type UnlinkEvent = {
102
- name: 'unlink';
103
- args: [];
104
- };
105
- /**
106
- * The options that are passed to the {@link ~LinkActionsView#constructor} constructor.
107
- */
108
- export type LinkActionsViewOptions = {
109
- /**
110
- * Returns `true` when bookmark `id` matches the hash from `link`.
111
- */
112
- isScrollableToTarget: (href: string | undefined) => boolean;
113
- /**
114
- * Scrolls the view to the desired bookmark or open a link in new window.
115
- */
116
- scrollToTarget: (href: string) => void;
117
- };
@@ -1,173 +0,0 @@
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/linkactionsview
7
- */
8
- import { ButtonView, View, ViewCollection, FocusCycler } from 'ckeditor5/src/ui.js';
9
- import { FocusTracker, KeystrokeHandler } from 'ckeditor5/src/utils.js';
10
- import { icons } from 'ckeditor5/src/core.js';
11
- import { ensureSafeUrl, openLink } from '../utils.js';
12
- // See: #8833.
13
- // eslint-disable-next-line ckeditor5-rules/ckeditor-imports
14
- import '@ckeditor/ckeditor5-ui/theme/components/responsive-form/responsiveform.css';
15
- import '../../theme/linkactions.css';
16
- import unlinkIcon from '../../theme/icons/unlink.svg';
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
- * @inheritDoc
24
- */
25
- constructor(locale, linkConfig = {}, options) {
26
- super(locale);
27
- /**
28
- * Tracks information about DOM focus in the actions.
29
- */
30
- this.focusTracker = new FocusTracker();
31
- /**
32
- * An instance of the {@link module:utils/keystrokehandler~KeystrokeHandler}.
33
- */
34
- this.keystrokes = new KeystrokeHandler();
35
- /**
36
- * A collection of views that can be focused in the view.
37
- */
38
- this._focusables = new ViewCollection();
39
- const t = locale.t;
40
- this._options = options;
41
- this.previewButtonView = this._createPreviewButton();
42
- this.unlinkButtonView = this._createButton(t('Unlink'), unlinkIcon, 'unlink');
43
- this.editButtonView = this._createButton(t('Edit link'), icons.pencil, 'edit');
44
- this.set('href', undefined);
45
- this._linkConfig = linkConfig;
46
- this._focusCycler = new FocusCycler({
47
- focusables: this._focusables,
48
- focusTracker: this.focusTracker,
49
- keystrokeHandler: this.keystrokes,
50
- actions: {
51
- // Navigate fields backwards using the Shift + Tab keystroke.
52
- focusPrevious: 'shift + tab',
53
- // Navigate fields forwards using the Tab key.
54
- focusNext: 'tab'
55
- }
56
- });
57
- this.setTemplate({
58
- tag: 'div',
59
- attributes: {
60
- class: [
61
- 'ck',
62
- 'ck-link-actions',
63
- 'ck-responsive-form'
64
- ],
65
- // https://github.com/ckeditor/ckeditor5-link/issues/90
66
- tabindex: '-1'
67
- },
68
- children: [
69
- this.previewButtonView,
70
- this.editButtonView,
71
- this.unlinkButtonView
72
- ]
73
- });
74
- }
75
- /**
76
- * @inheritDoc
77
- */
78
- render() {
79
- super.render();
80
- const childViews = [
81
- this.previewButtonView,
82
- this.editButtonView,
83
- this.unlinkButtonView
84
- ];
85
- childViews.forEach(v => {
86
- // Register the view as focusable.
87
- this._focusables.add(v);
88
- // Register the view in the focus tracker.
89
- this.focusTracker.add(v.element);
90
- });
91
- // Start listening for the keystrokes coming from #element.
92
- this.keystrokes.listenTo(this.element);
93
- }
94
- /**
95
- * @inheritDoc
96
- */
97
- destroy() {
98
- super.destroy();
99
- this.focusTracker.destroy();
100
- this.keystrokes.destroy();
101
- }
102
- /**
103
- * Focuses the fist {@link #_focusables} in the actions.
104
- */
105
- focus() {
106
- this._focusCycler.focusFirst();
107
- }
108
- /**
109
- * Creates a button view.
110
- *
111
- * @param label The button label.
112
- * @param icon The button icon.
113
- * @param eventName An event name that the `ButtonView#execute` event will be delegated to.
114
- * @returns The button view instance.
115
- */
116
- _createButton(label, icon, eventName) {
117
- const button = new ButtonView(this.locale);
118
- button.set({
119
- label,
120
- icon,
121
- tooltip: true
122
- });
123
- button.delegate('execute').to(this, eventName);
124
- return button;
125
- }
126
- /**
127
- * Creates a link href preview button.
128
- *
129
- * @returns The button view instance.
130
- */
131
- _createPreviewButton() {
132
- const button = new ButtonView(this.locale);
133
- const bind = this.bindTemplate;
134
- const t = this.t;
135
- button.set({
136
- withText: true
137
- });
138
- button.extendTemplate({
139
- attributes: {
140
- class: [
141
- 'ck',
142
- 'ck-link-actions__preview'
143
- ],
144
- href: bind.to('href', href => href && ensureSafeUrl(href, this._linkConfig.allowedProtocols)),
145
- target: '_blank',
146
- rel: 'noopener noreferrer'
147
- },
148
- on: {
149
- click: bind.to(evt => {
150
- if (this._options && this._options.isScrollableToTarget(this.href)) {
151
- evt.preventDefault();
152
- this._options.scrollToTarget(this.href);
153
- }
154
- else {
155
- openLink(this.href);
156
- }
157
- })
158
- }
159
- });
160
- button.bind('tooltip').to(this, 'href', href => {
161
- if (this._options && this._options.isScrollableToTarget(href)) {
162
- return t('Scroll to target');
163
- }
164
- return t('Open link in new tab');
165
- });
166
- button.bind('label').to(this, 'href', href => {
167
- return href || t('This link has no URL');
168
- });
169
- button.bind('isEnabled').to(this, 'href', href => !!href);
170
- button.template.tag = 'a';
171
- return button;
172
- }
173
- }
@@ -1 +0,0 @@
1
- <svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="m11.077 15 .991-1.416a.75.75 0 1 1 1.229.86l-1.148 1.64a.748.748 0 0 1-.217.206 5.251 5.251 0 0 1-8.503-5.955.741.741 0 0 1 .12-.274l1.147-1.639a.75.75 0 1 1 1.228.86L4.933 10.7l.006.003a3.75 3.75 0 0 0 6.132 4.294l.006.004zm5.494-5.335a.748.748 0 0 1-.12.274l-1.147 1.639a.75.75 0 1 1-1.228-.86l.86-1.23a3.75 3.75 0 0 0-6.144-4.301l-.86 1.229a.75.75 0 0 1-1.229-.86l1.148-1.64a.748.748 0 0 1 .217-.206 5.251 5.251 0 0 1 8.503 5.955zm-4.563-2.532a.75.75 0 0 1 .184 1.045l-3.155 4.505a.75.75 0 1 1-1.229-.86l3.155-4.506a.75.75 0 0 1 1.045-.184z"/></svg>
@@ -1 +0,0 @@
1
- <svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="m11.077 15 .991-1.416a.75.75 0 1 1 1.229.86l-1.148 1.64a.748.748 0 0 1-.217.206 5.251 5.251 0 0 1-8.503-5.955.741.741 0 0 1 .12-.274l1.147-1.639a.75.75 0 1 1 1.228.86L4.933 10.7l.006.003a3.75 3.75 0 0 0 6.132 4.294l.006.004zm5.494-5.335a.748.748 0 0 1-.12.274l-1.147 1.639a.75.75 0 1 1-1.228-.86l.86-1.23a3.75 3.75 0 0 0-6.144-4.301l-.86 1.229a.75.75 0 0 1-1.229-.86l1.148-1.64a.748.748 0 0 1 .217-.206 5.251 5.251 0 0 1 8.503 5.955zm-4.563-2.532a.75.75 0 0 1 .184 1.045l-3.155 4.505a.75.75 0 1 1-1.229-.86l3.155-4.506a.75.75 0 0 1 1.045-.184zm4.919 10.562-1.414 1.414a.75.75 0 1 1-1.06-1.06l1.414-1.415-1.415-1.414a.75.75 0 0 1 1.061-1.06l1.414 1.414 1.414-1.415a.75.75 0 0 1 1.061 1.061l-1.414 1.414 1.414 1.415a.75.75 0 0 1-1.06 1.06l-1.415-1.414z"/></svg>
@@ -1,32 +0,0 @@
1
- /*
2
- * 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
- @import "@ckeditor/ckeditor5-ui/theme/mixins/_rwd.css";
7
-
8
- .ck.ck-link-actions {
9
- display: flex;
10
- flex-direction: row;
11
- flex-wrap: nowrap;
12
-
13
- & .ck-link-actions__preview {
14
- display: inline-block;
15
-
16
- & .ck-button__label {
17
- overflow: hidden;
18
- }
19
- }
20
-
21
- @mixin ck-media-phone {
22
- flex-wrap: wrap;
23
-
24
- & .ck-link-actions__preview {
25
- flex-basis: 100%;
26
- }
27
-
28
- & .ck-button:not(.ck-link-actions__preview) {
29
- flex-basis: 50%;
30
- }
31
- }
32
- }