@ckeditor/ckeditor5-link 0.0.0-internal-20241017.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 (384) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/LICENSE.md +21 -0
  3. package/README.md +26 -0
  4. package/build/link.js +5 -0
  5. package/build/translations/ar.js +1 -0
  6. package/build/translations/ast.js +1 -0
  7. package/build/translations/az.js +1 -0
  8. package/build/translations/bg.js +1 -0
  9. package/build/translations/bn.js +1 -0
  10. package/build/translations/ca.js +1 -0
  11. package/build/translations/cs.js +1 -0
  12. package/build/translations/da.js +1 -0
  13. package/build/translations/de-ch.js +1 -0
  14. package/build/translations/de.js +1 -0
  15. package/build/translations/el.js +1 -0
  16. package/build/translations/en-au.js +1 -0
  17. package/build/translations/en-gb.js +1 -0
  18. package/build/translations/eo.js +1 -0
  19. package/build/translations/es.js +1 -0
  20. package/build/translations/et.js +1 -0
  21. package/build/translations/eu.js +1 -0
  22. package/build/translations/fa.js +1 -0
  23. package/build/translations/fi.js +1 -0
  24. package/build/translations/fr.js +1 -0
  25. package/build/translations/gl.js +1 -0
  26. package/build/translations/he.js +1 -0
  27. package/build/translations/hi.js +1 -0
  28. package/build/translations/hr.js +1 -0
  29. package/build/translations/hu.js +1 -0
  30. package/build/translations/hy.js +1 -0
  31. package/build/translations/id.js +1 -0
  32. package/build/translations/it.js +1 -0
  33. package/build/translations/ja.js +1 -0
  34. package/build/translations/km.js +1 -0
  35. package/build/translations/kn.js +1 -0
  36. package/build/translations/ko.js +1 -0
  37. package/build/translations/ku.js +1 -0
  38. package/build/translations/lt.js +1 -0
  39. package/build/translations/lv.js +1 -0
  40. package/build/translations/ms.js +1 -0
  41. package/build/translations/nb.js +1 -0
  42. package/build/translations/ne.js +1 -0
  43. package/build/translations/nl.js +1 -0
  44. package/build/translations/no.js +1 -0
  45. package/build/translations/pl.js +1 -0
  46. package/build/translations/pt-br.js +1 -0
  47. package/build/translations/pt.js +1 -0
  48. package/build/translations/ro.js +1 -0
  49. package/build/translations/ru.js +1 -0
  50. package/build/translations/sk.js +1 -0
  51. package/build/translations/sq.js +1 -0
  52. package/build/translations/sr-latn.js +1 -0
  53. package/build/translations/sr.js +1 -0
  54. package/build/translations/sv.js +1 -0
  55. package/build/translations/th.js +1 -0
  56. package/build/translations/ti.js +1 -0
  57. package/build/translations/tk.js +1 -0
  58. package/build/translations/tr.js +1 -0
  59. package/build/translations/tt.js +1 -0
  60. package/build/translations/ug.js +1 -0
  61. package/build/translations/uk.js +1 -0
  62. package/build/translations/ur.js +1 -0
  63. package/build/translations/uz.js +1 -0
  64. package/build/translations/vi.js +1 -0
  65. package/build/translations/zh-cn.js +1 -0
  66. package/build/translations/zh.js +1 -0
  67. package/ckeditor5-metadata.json +78 -0
  68. package/dist/augmentation.d.ts +34 -0
  69. package/dist/autolink.d.ts +83 -0
  70. package/dist/index-content.css +4 -0
  71. package/dist/index-editor.css +98 -0
  72. package/dist/index.css +148 -0
  73. package/dist/index.css.map +1 -0
  74. package/dist/index.d.ts +25 -0
  75. package/dist/index.js +2567 -0
  76. package/dist/index.js.map +1 -0
  77. package/dist/link.d.ts +35 -0
  78. package/dist/linkcommand.d.ts +136 -0
  79. package/dist/linkconfig.d.ts +294 -0
  80. package/dist/linkediting.d.ts +78 -0
  81. package/dist/linkimage.d.ts +35 -0
  82. package/dist/linkimageediting.d.ts +47 -0
  83. package/dist/linkimageui.d.ts +48 -0
  84. package/dist/linkui.d.ts +177 -0
  85. package/dist/translations/ar.d.ts +8 -0
  86. package/dist/translations/ar.js +5 -0
  87. package/dist/translations/ar.umd.js +11 -0
  88. package/dist/translations/ast.d.ts +8 -0
  89. package/dist/translations/ast.js +5 -0
  90. package/dist/translations/ast.umd.js +11 -0
  91. package/dist/translations/az.d.ts +8 -0
  92. package/dist/translations/az.js +5 -0
  93. package/dist/translations/az.umd.js +11 -0
  94. package/dist/translations/bg.d.ts +8 -0
  95. package/dist/translations/bg.js +5 -0
  96. package/dist/translations/bg.umd.js +11 -0
  97. package/dist/translations/bn.d.ts +8 -0
  98. package/dist/translations/bn.js +5 -0
  99. package/dist/translations/bn.umd.js +11 -0
  100. package/dist/translations/ca.d.ts +8 -0
  101. package/dist/translations/ca.js +5 -0
  102. package/dist/translations/ca.umd.js +11 -0
  103. package/dist/translations/cs.d.ts +8 -0
  104. package/dist/translations/cs.js +5 -0
  105. package/dist/translations/cs.umd.js +11 -0
  106. package/dist/translations/da.d.ts +8 -0
  107. package/dist/translations/da.js +5 -0
  108. package/dist/translations/da.umd.js +11 -0
  109. package/dist/translations/de-ch.d.ts +8 -0
  110. package/dist/translations/de-ch.js +5 -0
  111. package/dist/translations/de-ch.umd.js +11 -0
  112. package/dist/translations/de.d.ts +8 -0
  113. package/dist/translations/de.js +5 -0
  114. package/dist/translations/de.umd.js +11 -0
  115. package/dist/translations/el.d.ts +8 -0
  116. package/dist/translations/el.js +5 -0
  117. package/dist/translations/el.umd.js +11 -0
  118. package/dist/translations/en-au.d.ts +8 -0
  119. package/dist/translations/en-au.js +5 -0
  120. package/dist/translations/en-au.umd.js +11 -0
  121. package/dist/translations/en-gb.d.ts +8 -0
  122. package/dist/translations/en-gb.js +5 -0
  123. package/dist/translations/en-gb.umd.js +11 -0
  124. package/dist/translations/en.d.ts +8 -0
  125. package/dist/translations/en.js +5 -0
  126. package/dist/translations/en.umd.js +11 -0
  127. package/dist/translations/eo.d.ts +8 -0
  128. package/dist/translations/eo.js +5 -0
  129. package/dist/translations/eo.umd.js +11 -0
  130. package/dist/translations/es.d.ts +8 -0
  131. package/dist/translations/es.js +5 -0
  132. package/dist/translations/es.umd.js +11 -0
  133. package/dist/translations/et.d.ts +8 -0
  134. package/dist/translations/et.js +5 -0
  135. package/dist/translations/et.umd.js +11 -0
  136. package/dist/translations/eu.d.ts +8 -0
  137. package/dist/translations/eu.js +5 -0
  138. package/dist/translations/eu.umd.js +11 -0
  139. package/dist/translations/fa.d.ts +8 -0
  140. package/dist/translations/fa.js +5 -0
  141. package/dist/translations/fa.umd.js +11 -0
  142. package/dist/translations/fi.d.ts +8 -0
  143. package/dist/translations/fi.js +5 -0
  144. package/dist/translations/fi.umd.js +11 -0
  145. package/dist/translations/fr.d.ts +8 -0
  146. package/dist/translations/fr.js +5 -0
  147. package/dist/translations/fr.umd.js +11 -0
  148. package/dist/translations/gl.d.ts +8 -0
  149. package/dist/translations/gl.js +5 -0
  150. package/dist/translations/gl.umd.js +11 -0
  151. package/dist/translations/he.d.ts +8 -0
  152. package/dist/translations/he.js +5 -0
  153. package/dist/translations/he.umd.js +11 -0
  154. package/dist/translations/hi.d.ts +8 -0
  155. package/dist/translations/hi.js +5 -0
  156. package/dist/translations/hi.umd.js +11 -0
  157. package/dist/translations/hr.d.ts +8 -0
  158. package/dist/translations/hr.js +5 -0
  159. package/dist/translations/hr.umd.js +11 -0
  160. package/dist/translations/hu.d.ts +8 -0
  161. package/dist/translations/hu.js +5 -0
  162. package/dist/translations/hu.umd.js +11 -0
  163. package/dist/translations/hy.d.ts +8 -0
  164. package/dist/translations/hy.js +5 -0
  165. package/dist/translations/hy.umd.js +11 -0
  166. package/dist/translations/id.d.ts +8 -0
  167. package/dist/translations/id.js +5 -0
  168. package/dist/translations/id.umd.js +11 -0
  169. package/dist/translations/it.d.ts +8 -0
  170. package/dist/translations/it.js +5 -0
  171. package/dist/translations/it.umd.js +11 -0
  172. package/dist/translations/ja.d.ts +8 -0
  173. package/dist/translations/ja.js +5 -0
  174. package/dist/translations/ja.umd.js +11 -0
  175. package/dist/translations/km.d.ts +8 -0
  176. package/dist/translations/km.js +5 -0
  177. package/dist/translations/km.umd.js +11 -0
  178. package/dist/translations/kn.d.ts +8 -0
  179. package/dist/translations/kn.js +5 -0
  180. package/dist/translations/kn.umd.js +11 -0
  181. package/dist/translations/ko.d.ts +8 -0
  182. package/dist/translations/ko.js +5 -0
  183. package/dist/translations/ko.umd.js +11 -0
  184. package/dist/translations/ku.d.ts +8 -0
  185. package/dist/translations/ku.js +5 -0
  186. package/dist/translations/ku.umd.js +11 -0
  187. package/dist/translations/lt.d.ts +8 -0
  188. package/dist/translations/lt.js +5 -0
  189. package/dist/translations/lt.umd.js +11 -0
  190. package/dist/translations/lv.d.ts +8 -0
  191. package/dist/translations/lv.js +5 -0
  192. package/dist/translations/lv.umd.js +11 -0
  193. package/dist/translations/ms.d.ts +8 -0
  194. package/dist/translations/ms.js +5 -0
  195. package/dist/translations/ms.umd.js +11 -0
  196. package/dist/translations/nb.d.ts +8 -0
  197. package/dist/translations/nb.js +5 -0
  198. package/dist/translations/nb.umd.js +11 -0
  199. package/dist/translations/ne.d.ts +8 -0
  200. package/dist/translations/ne.js +5 -0
  201. package/dist/translations/ne.umd.js +11 -0
  202. package/dist/translations/nl.d.ts +8 -0
  203. package/dist/translations/nl.js +5 -0
  204. package/dist/translations/nl.umd.js +11 -0
  205. package/dist/translations/no.d.ts +8 -0
  206. package/dist/translations/no.js +5 -0
  207. package/dist/translations/no.umd.js +11 -0
  208. package/dist/translations/pl.d.ts +8 -0
  209. package/dist/translations/pl.js +5 -0
  210. package/dist/translations/pl.umd.js +11 -0
  211. package/dist/translations/pt-br.d.ts +8 -0
  212. package/dist/translations/pt-br.js +5 -0
  213. package/dist/translations/pt-br.umd.js +11 -0
  214. package/dist/translations/pt.d.ts +8 -0
  215. package/dist/translations/pt.js +5 -0
  216. package/dist/translations/pt.umd.js +11 -0
  217. package/dist/translations/ro.d.ts +8 -0
  218. package/dist/translations/ro.js +5 -0
  219. package/dist/translations/ro.umd.js +11 -0
  220. package/dist/translations/ru.d.ts +8 -0
  221. package/dist/translations/ru.js +5 -0
  222. package/dist/translations/ru.umd.js +11 -0
  223. package/dist/translations/sk.d.ts +8 -0
  224. package/dist/translations/sk.js +5 -0
  225. package/dist/translations/sk.umd.js +11 -0
  226. package/dist/translations/sq.d.ts +8 -0
  227. package/dist/translations/sq.js +5 -0
  228. package/dist/translations/sq.umd.js +11 -0
  229. package/dist/translations/sr-latn.d.ts +8 -0
  230. package/dist/translations/sr-latn.js +5 -0
  231. package/dist/translations/sr-latn.umd.js +11 -0
  232. package/dist/translations/sr.d.ts +8 -0
  233. package/dist/translations/sr.js +5 -0
  234. package/dist/translations/sr.umd.js +11 -0
  235. package/dist/translations/sv.d.ts +8 -0
  236. package/dist/translations/sv.js +5 -0
  237. package/dist/translations/sv.umd.js +11 -0
  238. package/dist/translations/th.d.ts +8 -0
  239. package/dist/translations/th.js +5 -0
  240. package/dist/translations/th.umd.js +11 -0
  241. package/dist/translations/ti.d.ts +8 -0
  242. package/dist/translations/ti.js +5 -0
  243. package/dist/translations/ti.umd.js +11 -0
  244. package/dist/translations/tk.d.ts +8 -0
  245. package/dist/translations/tk.js +5 -0
  246. package/dist/translations/tk.umd.js +11 -0
  247. package/dist/translations/tr.d.ts +8 -0
  248. package/dist/translations/tr.js +5 -0
  249. package/dist/translations/tr.umd.js +11 -0
  250. package/dist/translations/tt.d.ts +8 -0
  251. package/dist/translations/tt.js +5 -0
  252. package/dist/translations/tt.umd.js +11 -0
  253. package/dist/translations/ug.d.ts +8 -0
  254. package/dist/translations/ug.js +5 -0
  255. package/dist/translations/ug.umd.js +11 -0
  256. package/dist/translations/uk.d.ts +8 -0
  257. package/dist/translations/uk.js +5 -0
  258. package/dist/translations/uk.umd.js +11 -0
  259. package/dist/translations/ur.d.ts +8 -0
  260. package/dist/translations/ur.js +5 -0
  261. package/dist/translations/ur.umd.js +11 -0
  262. package/dist/translations/uz.d.ts +8 -0
  263. package/dist/translations/uz.js +5 -0
  264. package/dist/translations/uz.umd.js +11 -0
  265. package/dist/translations/vi.d.ts +8 -0
  266. package/dist/translations/vi.js +5 -0
  267. package/dist/translations/vi.umd.js +11 -0
  268. package/dist/translations/zh-cn.d.ts +8 -0
  269. package/dist/translations/zh-cn.js +5 -0
  270. package/dist/translations/zh-cn.umd.js +11 -0
  271. package/dist/translations/zh.d.ts +8 -0
  272. package/dist/translations/zh.js +5 -0
  273. package/dist/translations/zh.umd.js +11 -0
  274. package/dist/ui/linkactionsview.d.ts +107 -0
  275. package/dist/ui/linkformview.d.ts +175 -0
  276. package/dist/unlinkcommand.d.ts +35 -0
  277. package/dist/utils/automaticdecorators.d.ts +49 -0
  278. package/dist/utils/manualdecorator.d.ts +76 -0
  279. package/dist/utils.d.ts +84 -0
  280. package/lang/contexts.json +14 -0
  281. package/lang/translations/ar.po +66 -0
  282. package/lang/translations/ast.po +66 -0
  283. package/lang/translations/az.po +66 -0
  284. package/lang/translations/bg.po +66 -0
  285. package/lang/translations/bn.po +68 -0
  286. package/lang/translations/ca.po +66 -0
  287. package/lang/translations/cs.po +66 -0
  288. package/lang/translations/da.po +66 -0
  289. package/lang/translations/de-ch.po +66 -0
  290. package/lang/translations/de.po +66 -0
  291. package/lang/translations/el.po +66 -0
  292. package/lang/translations/en-au.po +66 -0
  293. package/lang/translations/en-gb.po +66 -0
  294. package/lang/translations/en.po +66 -0
  295. package/lang/translations/eo.po +66 -0
  296. package/lang/translations/es.po +66 -0
  297. package/lang/translations/et.po +66 -0
  298. package/lang/translations/eu.po +66 -0
  299. package/lang/translations/fa.po +66 -0
  300. package/lang/translations/fi.po +66 -0
  301. package/lang/translations/fr.po +66 -0
  302. package/lang/translations/gl.po +66 -0
  303. package/lang/translations/he.po +66 -0
  304. package/lang/translations/hi.po +66 -0
  305. package/lang/translations/hr.po +66 -0
  306. package/lang/translations/hu.po +66 -0
  307. package/lang/translations/hy.po +66 -0
  308. package/lang/translations/id.po +66 -0
  309. package/lang/translations/it.po +66 -0
  310. package/lang/translations/ja.po +66 -0
  311. package/lang/translations/km.po +66 -0
  312. package/lang/translations/kn.po +66 -0
  313. package/lang/translations/ko.po +66 -0
  314. package/lang/translations/ku.po +66 -0
  315. package/lang/translations/lt.po +66 -0
  316. package/lang/translations/lv.po +66 -0
  317. package/lang/translations/ms.po +66 -0
  318. package/lang/translations/nb.po +66 -0
  319. package/lang/translations/ne.po +66 -0
  320. package/lang/translations/nl.po +66 -0
  321. package/lang/translations/no.po +66 -0
  322. package/lang/translations/pl.po +66 -0
  323. package/lang/translations/pt-br.po +66 -0
  324. package/lang/translations/pt.po +66 -0
  325. package/lang/translations/ro.po +66 -0
  326. package/lang/translations/ru.po +66 -0
  327. package/lang/translations/sk.po +66 -0
  328. package/lang/translations/sq.po +66 -0
  329. package/lang/translations/sr-latn.po +66 -0
  330. package/lang/translations/sr.po +66 -0
  331. package/lang/translations/sv.po +66 -0
  332. package/lang/translations/th.po +66 -0
  333. package/lang/translations/ti.po +66 -0
  334. package/lang/translations/tk.po +66 -0
  335. package/lang/translations/tr.po +66 -0
  336. package/lang/translations/tt.po +66 -0
  337. package/lang/translations/ug.po +66 -0
  338. package/lang/translations/uk.po +66 -0
  339. package/lang/translations/ur.po +66 -0
  340. package/lang/translations/uz.po +66 -0
  341. package/lang/translations/vi.po +66 -0
  342. package/lang/translations/zh-cn.po +66 -0
  343. package/lang/translations/zh.po +66 -0
  344. package/package.json +46 -0
  345. package/src/augmentation.d.ts +30 -0
  346. package/src/augmentation.js +5 -0
  347. package/src/autolink.d.ts +79 -0
  348. package/src/autolink.js +290 -0
  349. package/src/index.d.ts +21 -0
  350. package/src/index.js +20 -0
  351. package/src/link.d.ts +31 -0
  352. package/src/link.js +37 -0
  353. package/src/linkcommand.d.ts +132 -0
  354. package/src/linkcommand.js +285 -0
  355. package/src/linkconfig.d.ts +290 -0
  356. package/src/linkconfig.js +5 -0
  357. package/src/linkediting.d.ts +74 -0
  358. package/src/linkediting.js +286 -0
  359. package/src/linkimage.d.ts +31 -0
  360. package/src/linkimage.js +37 -0
  361. package/src/linkimageediting.d.ts +43 -0
  362. package/src/linkimageediting.js +251 -0
  363. package/src/linkimageui.d.ts +44 -0
  364. package/src/linkimageui.js +102 -0
  365. package/src/linkui.d.ts +173 -0
  366. package/src/linkui.js +652 -0
  367. package/src/ui/linkactionsview.d.ts +103 -0
  368. package/src/ui/linkactionsview.js +157 -0
  369. package/src/ui/linkformview.d.ts +171 -0
  370. package/src/ui/linkformview.js +273 -0
  371. package/src/unlinkcommand.d.ts +31 -0
  372. package/src/unlinkcommand.js +66 -0
  373. package/src/utils/automaticdecorators.d.ts +45 -0
  374. package/src/utils/automaticdecorators.js +140 -0
  375. package/src/utils/manualdecorator.d.ts +72 -0
  376. package/src/utils/manualdecorator.js +47 -0
  377. package/src/utils.d.ts +80 -0
  378. package/src/utils.js +135 -0
  379. package/theme/icons/link.svg +1 -0
  380. package/theme/icons/unlink.svg +1 -0
  381. package/theme/link.css +10 -0
  382. package/theme/linkactions.css +32 -0
  383. package/theme/linkform.css +46 -0
  384. package/theme/linkimage.css +16 -0
@@ -0,0 +1,290 @@
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/linkconfig
7
+ */
8
+ import type { ArrayOrItem } from 'ckeditor5/src/utils.js';
9
+ /**
10
+ * The configuration of the {@link module:link/link~Link link feature}.
11
+ *
12
+ * ```ts
13
+ * ClassicEditor
14
+ * .create( editorElement, {
15
+ * link: ... // Link feature configuration.
16
+ * } )
17
+ * .then( ... )
18
+ * .catch( ... );
19
+ * ```
20
+ *
21
+ * See {@link module:core/editor/editorconfig~EditorConfig all editor options}.
22
+ */
23
+ export interface LinkConfig {
24
+ /**
25
+ * When set, the editor will add the given protocol to the link when the user creates a link without one.
26
+ * For example, when the user is creating a link and types `ckeditor.com` in the link form input, during link submission
27
+ * the editor will automatically add the `http://` protocol, so the link will look as follows: `http://ckeditor.com`.
28
+ *
29
+ * The feature also provides email address auto-detection. When you submit `hello@example.com`,
30
+ * the plugin will automatically change it to `mailto:hello@example.com`.
31
+ *
32
+ * ```ts
33
+ * ClassicEditor
34
+ * .create( editorElement, {
35
+ * link: {
36
+ * defaultProtocol: 'http://'
37
+ * }
38
+ * } )
39
+ * .then( ... )
40
+ * .catch( ... );
41
+ * ```
42
+ *
43
+ * **NOTE:** If no configuration is provided, the editor will not auto-fix the links.
44
+ */
45
+ defaultProtocol?: string;
46
+ /**
47
+ * This is a protocols whitelist that can be used in links, defined as an array of strings.
48
+ * When not set, the editor will use a default list of allowed protocols.
49
+ *
50
+ * **Note:** Use this with caution and at your own risk - adding unsafe protocols like `javascript:`
51
+ * can result in serious security vulnerabilities!
52
+ *
53
+ * ```ts
54
+ * ClassicEditor
55
+ * .create( editorElement, {
56
+ * link: {
57
+ * allowedProtocols: [ 'http', 'https', 'ftp', 'tel', 'mailto', 'ssh' ]
58
+ * }
59
+ * } )
60
+ * .then( ... )
61
+ * .catch( ... );
62
+ * ```
63
+ *
64
+ */
65
+ allowedProtocols?: Array<string>;
66
+ /**
67
+ * When set to `true`, the form will accept an empty value in the URL field, creating a link with an empty `href` (`<a href="">`).
68
+ *
69
+ * ```ts
70
+ * ClassicEditor
71
+ * .create( editorElement, {
72
+ * link: {
73
+ * allowCreatingEmptyLinks: true
74
+ * }
75
+ * } )
76
+ * .then( ... )
77
+ * .catch( ... );
78
+ * ```
79
+ *
80
+ * **NOTE:** This option only adds form validation. If a link with an empty `href` is loaded into the editor, it will be left as-is.
81
+ *
82
+ * @default false
83
+ */
84
+ allowCreatingEmptyLinks?: boolean;
85
+ /**
86
+ * When set to `true`, the `target="blank"` and `rel="noopener noreferrer"` attributes are automatically added to all external links
87
+ * in the editor. "External links" are all links in the editor content starting with `http`, `https`, or `//`.
88
+ *
89
+ * ```ts
90
+ * ClassicEditor
91
+ * .create( editorElement, {
92
+ * link: {
93
+ * addTargetToExternalLinks: true
94
+ * }
95
+ * } )
96
+ * .then( ... )
97
+ * .catch( ... );
98
+ * ```
99
+ *
100
+ * Internally, this option activates a predefined {@link module:link/linkconfig~LinkConfig#decorators automatic link decorator}
101
+ * that extends all external links with the `target` and `rel` attributes.
102
+ *
103
+ * **Note**: To control the `target` and `rel` attributes of specific links in the edited content, a dedicated
104
+ * {@link module:link/linkconfig~LinkDecoratorManualDefinition manual} decorator must be defined in the
105
+ * {@link module:link/linkconfig~LinkConfig#decorators `config.link.decorators`} array. In such scenario,
106
+ * the `config.link.addTargetToExternalLinks` option should remain `undefined` or `false` to not interfere with the manual decorator.
107
+ *
108
+ * It is possible to add other {@link module:link/linkconfig~LinkDecoratorAutomaticDefinition automatic}
109
+ * or {@link module:link/linkconfig~LinkDecoratorManualDefinition manual} link decorators when this option is active.
110
+ *
111
+ * More information about decorators can be found in the {@link module:link/linkconfig~LinkConfig#decorators decorators configuration}
112
+ * reference.
113
+ *
114
+ * @default false
115
+ */
116
+ addTargetToExternalLinks?: boolean;
117
+ /**
118
+ * Decorators provide an easy way to configure and manage additional link attributes in the editor content. There are
119
+ * two types of link decorators:
120
+ *
121
+ * * {@link module:link/linkconfig~LinkDecoratorAutomaticDefinition Automatic} &ndash; They match links against pre–defined rules and
122
+ * manage their attributes based on the results.
123
+ * * {@link module:link/linkconfig~LinkDecoratorManualDefinition Manual} &ndash; They allow users to control link attributes
124
+ * individually, using the editor UI.
125
+ *
126
+ * Link decorators are defined as objects with key-value pairs, where the key is the name provided for a given decorator and the
127
+ * value is the decorator definition.
128
+ *
129
+ * The name of the decorator also corresponds to the {@glink framework/architecture/editing-engine#text-attributes text
130
+ * attribute} in the model. For instance, the `isExternal` decorator below is represented as a `linkIsExternal` attribute in the model.
131
+ *
132
+ * ```ts
133
+ * ClassicEditor
134
+ * .create( editorElement, {
135
+ * link: {
136
+ * decorators: {
137
+ * isExternal: {
138
+ * mode: 'automatic',
139
+ * callback: url => url.startsWith( 'http://' ),
140
+ * attributes: {
141
+ * target: '_blank',
142
+ * rel: 'noopener noreferrer'
143
+ * }
144
+ * },
145
+ * isDownloadable: {
146
+ * mode: 'manual',
147
+ * label: 'Downloadable',
148
+ * attributes: {
149
+ * download: 'file.png',
150
+ * }
151
+ * },
152
+ * // ...
153
+ * }
154
+ * }
155
+ * } )
156
+ * .then( ... )
157
+ * .catch( ... );
158
+ * ```
159
+ *
160
+ * To learn more about the configuration syntax, check out the {@link module:link/linkconfig~LinkDecoratorAutomaticDefinition automatic}
161
+ * and {@link module:link/linkconfig~LinkDecoratorManualDefinition manual} decorator option reference.
162
+ *
163
+ * **Warning:** Currently, link decorators work independently of one another and no conflict resolution mechanism exists.
164
+ * For example, configuring the `target` attribute using both an automatic and a manual decorator at the same time could end up with
165
+ * quirky results. The same applies if multiple manual or automatic decorators were defined for the same attribute.
166
+ *
167
+ * **Note**: Since the `target` attribute management for external links is a common use case, there is a predefined automatic decorator
168
+ * dedicated for that purpose which can be enabled by turning a single option on. Check out the
169
+ * {@link module:link/linkconfig~LinkConfig#addTargetToExternalLinks `config.link.addTargetToExternalLinks`}
170
+ * configuration description to learn more.
171
+ *
172
+ * See also the {@glink features/link#custom-link-attributes-decorators link feature guide} for more information.
173
+ */
174
+ decorators?: Record<string, LinkDecoratorDefinition>;
175
+ }
176
+ /**
177
+ * A link decorator definition. Two types implement this definition:
178
+ *
179
+ * * {@link module:link/linkconfig~LinkDecoratorManualDefinition}
180
+ * * {@link module:link/linkconfig~LinkDecoratorAutomaticDefinition}
181
+ *
182
+ * Refer to their document for more information about available options or to the
183
+ * {@glink features/link#custom-link-attributes-decorators link feature guide} for general information.
184
+ */
185
+ export type LinkDecoratorDefinition = LinkDecoratorAutomaticDefinition | LinkDecoratorManualDefinition;
186
+ /**
187
+ * Describes an automatic {@link module:link/linkconfig~LinkConfig#decorators link decorator}. This decorator type matches
188
+ * all links in the editor content against a function that decides whether the link should receive a pre–defined set of attributes.
189
+ *
190
+ * It takes an object with key-value pairs of attributes and a callback function that must return a Boolean value based on the link's
191
+ * `href` (URL). When the callback returns `true`, attributes are applied to the link.
192
+ *
193
+ * For example, to add the `target="_blank"` attribute to all links in the editor starting with `http://`, the
194
+ * configuration could look like this:
195
+ *
196
+ * ```ts
197
+ * {
198
+ * mode: 'automatic',
199
+ * callback: url => url.startsWith( 'http://' ),
200
+ * attributes: {
201
+ * target: '_blank'
202
+ * }
203
+ * }
204
+ * ```
205
+ *
206
+ * **Note**: Since the `target` attribute management for external links is a common use case, there is a predefined automatic decorator
207
+ * dedicated for that purpose that can be enabled by turning a single option on. Check out the
208
+ * {@link module:link/linkconfig~LinkConfig#addTargetToExternalLinks `config.link.addTargetToExternalLinks`}
209
+ * configuration description to learn more.
210
+ */
211
+ export interface LinkDecoratorAutomaticDefinition {
212
+ /**
213
+ * Link decorator type. It is `'automatic'` for all automatic decorators.
214
+ */
215
+ mode: 'automatic';
216
+ /**
217
+ * Takes a `url` as a parameter and returns `true` if the `attributes` should be applied to the link.
218
+ */
219
+ callback: (url: string | null) => boolean;
220
+ /**
221
+ * Key-value pairs used as link attributes added to the output during the
222
+ * {@glink framework/architecture/editing-engine#conversion downcasting}.
223
+ * Attributes should follow the {@link module:engine/view/elementdefinition~ElementDefinition} syntax.
224
+ */
225
+ attributes?: Record<string, string>;
226
+ /**
227
+ * Key-value pairs used as link styles added to the output during the
228
+ * {@glink framework/architecture/editing-engine#conversion downcasting}.
229
+ * Styles should follow the {@link module:engine/view/elementdefinition~ElementDefinition} syntax.
230
+ */
231
+ styles?: Record<string, string>;
232
+ /**
233
+ * Class names used as link classes added to the output during the
234
+ * {@glink framework/architecture/editing-engine#conversion downcasting}.
235
+ * Classes should follow the {@link module:engine/view/elementdefinition~ElementDefinition} syntax.
236
+ */
237
+ classes?: ArrayOrItem<string>;
238
+ }
239
+ /**
240
+ * Describes a manual {@link module:link/linkconfig~LinkConfig#decorators link decorator}. This decorator type is represented in
241
+ * the link feature's {@link module:link/linkui user interface} as a switch that the user can use to control the presence
242
+ * of a predefined set of attributes.
243
+ *
244
+ * For instance, to allow the users to manually control the presence of the `target="_blank"` and
245
+ * `rel="noopener noreferrer"` attributes on specific links, the decorator could look as follows:
246
+ *
247
+ * ```ts
248
+ * {
249
+ * mode: 'manual',
250
+ * label: 'Open in a new tab',
251
+ * defaultValue: true,
252
+ * attributes: {
253
+ * target: '_blank',
254
+ * rel: 'noopener noreferrer'
255
+ * }
256
+ * }
257
+ * ```
258
+ */
259
+ export interface LinkDecoratorManualDefinition {
260
+ /**
261
+ * Link decorator type. It is `'manual'` for all manual decorators.
262
+ */
263
+ mode: 'manual';
264
+ /**
265
+ * The label of the UI button that the user can use to control the presence of link attributes.
266
+ */
267
+ label: string;
268
+ /**
269
+ * Key-value pairs used as link attributes added to the output during the
270
+ * {@glink framework/architecture/editing-engine#conversion downcasting}.
271
+ * Attributes should follow the {@link module:engine/view/elementdefinition~ElementDefinition} syntax.
272
+ */
273
+ attributes?: Record<string, string>;
274
+ /**
275
+ * Key-value pairs used as link styles added to the output during the
276
+ * {@glink framework/architecture/editing-engine#conversion downcasting}.
277
+ * Styles should follow the {@link module:engine/view/elementdefinition~ElementDefinition} syntax.
278
+ */
279
+ styles?: Record<string, string>;
280
+ /**
281
+ * Class names used as link classes added to the output during the
282
+ * {@glink framework/architecture/editing-engine#conversion downcasting}.
283
+ * Classes should follow the {@link module:engine/view/elementdefinition~ElementDefinition} syntax.
284
+ */
285
+ classes?: ArrayOrItem<string>;
286
+ /**
287
+ * Controls whether the decorator is "on" by default.
288
+ */
289
+ defaultValue?: boolean;
290
+ }
@@ -0,0 +1,5 @@
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
+ export {};
@@ -0,0 +1,74 @@
1
+ /**
2
+ * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
3
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
+ */
5
+ /**
6
+ * @module link/linkediting
7
+ */
8
+ import { Plugin, type Editor } from 'ckeditor5/src/core.js';
9
+ import { Input, TwoStepCaretMovement } from 'ckeditor5/src/typing.js';
10
+ import { ClipboardPipeline } from 'ckeditor5/src/clipboard.js';
11
+ import '../theme/link.css';
12
+ /**
13
+ * The link engine feature.
14
+ *
15
+ * It introduces the `linkHref="url"` attribute in the model which renders to the view as a `<a href="url">` element
16
+ * as well as `'link'` and `'unlink'` commands.
17
+ */
18
+ export default class LinkEditing extends Plugin {
19
+ /**
20
+ * @inheritDoc
21
+ */
22
+ static get pluginName(): "LinkEditing";
23
+ /**
24
+ * @inheritDoc
25
+ */
26
+ static get isOfficialPlugin(): true;
27
+ /**
28
+ * @inheritDoc
29
+ */
30
+ static get requires(): readonly [typeof TwoStepCaretMovement, typeof Input, typeof ClipboardPipeline];
31
+ /**
32
+ * @inheritDoc
33
+ */
34
+ constructor(editor: Editor);
35
+ /**
36
+ * @inheritDoc
37
+ */
38
+ init(): void;
39
+ /**
40
+ * Processes an array of configured {@link module:link/linkconfig~LinkDecoratorAutomaticDefinition automatic decorators}
41
+ * and registers a {@link module:engine/conversion/downcastdispatcher~DowncastDispatcher downcast dispatcher}
42
+ * for each one of them. Downcast dispatchers are obtained using the
43
+ * {@link module:link/utils/automaticdecorators~AutomaticDecorators#getDispatcher} method.
44
+ *
45
+ * **Note**: This method also activates the automatic external link decorator if enabled with
46
+ * {@link module:link/linkconfig~LinkConfig#addTargetToExternalLinks `config.link.addTargetToExternalLinks`}.
47
+ */
48
+ private _enableAutomaticDecorators;
49
+ /**
50
+ * Processes an array of configured {@link module:link/linkconfig~LinkDecoratorManualDefinition manual decorators},
51
+ * transforms them into {@link module:link/utils/manualdecorator~ManualDecorator} instances and stores them in the
52
+ * {@link module:link/linkcommand~LinkCommand#manualDecorators} collection (a model for manual decorators state).
53
+ *
54
+ * Also registers an {@link module:engine/conversion/downcasthelpers~DowncastHelpers#attributeToElement attribute-to-element}
55
+ * converter for each manual decorator and extends the {@link module:engine/model/schema~Schema model's schema}
56
+ * with adequate model attributes.
57
+ */
58
+ private _enableManualDecorators;
59
+ /**
60
+ * Attaches handlers for {@link module:engine/view/document~Document#event:enter} and
61
+ * {@link module:engine/view/document~Document#event:click} to enable link following.
62
+ */
63
+ private _enableLinkOpen;
64
+ /**
65
+ * Watches the DocumentSelection attribute changes and removes link decorator attributes when the linkHref attribute is removed.
66
+ *
67
+ * This is to ensure that there is no left-over link decorator attributes on the document selection that is no longer in a link.
68
+ */
69
+ private _enableSelectionAttributesFixer;
70
+ /**
71
+ * Enables URL fixing on pasting.
72
+ */
73
+ private _enableClipboardIntegration;
74
+ }
@@ -0,0 +1,286 @@
1
+ /**
2
+ * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
3
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
+ */
5
+ /**
6
+ * @module link/linkediting
7
+ */
8
+ import { Plugin } from 'ckeditor5/src/core.js';
9
+ import { Input, TwoStepCaretMovement, inlineHighlight } from 'ckeditor5/src/typing.js';
10
+ import { ClipboardPipeline } from 'ckeditor5/src/clipboard.js';
11
+ import { keyCodes, env } from 'ckeditor5/src/utils.js';
12
+ import LinkCommand from './linkcommand.js';
13
+ import UnlinkCommand from './unlinkcommand.js';
14
+ import ManualDecorator from './utils/manualdecorator.js';
15
+ import { createLinkElement, ensureSafeUrl, getLocalizedDecorators, normalizeDecorators, openLink, addLinkProtocolIfApplicable } from './utils.js';
16
+ import '../theme/link.css';
17
+ const HIGHLIGHT_CLASS = 'ck-link_selected';
18
+ const DECORATOR_AUTOMATIC = 'automatic';
19
+ const DECORATOR_MANUAL = 'manual';
20
+ const EXTERNAL_LINKS_REGEXP = /^(https?:)?\/\//;
21
+ /**
22
+ * The link engine feature.
23
+ *
24
+ * It introduces the `linkHref="url"` attribute in the model which renders to the view as a `<a href="url">` element
25
+ * as well as `'link'` and `'unlink'` commands.
26
+ */
27
+ export default class LinkEditing extends Plugin {
28
+ /**
29
+ * @inheritDoc
30
+ */
31
+ static get pluginName() {
32
+ return 'LinkEditing';
33
+ }
34
+ /**
35
+ * @inheritDoc
36
+ */
37
+ static get isOfficialPlugin() {
38
+ return true;
39
+ }
40
+ /**
41
+ * @inheritDoc
42
+ */
43
+ static get requires() {
44
+ // Clipboard is required for handling cut and paste events while typing over the link.
45
+ return [TwoStepCaretMovement, Input, ClipboardPipeline];
46
+ }
47
+ /**
48
+ * @inheritDoc
49
+ */
50
+ constructor(editor) {
51
+ super(editor);
52
+ editor.config.define('link', {
53
+ allowCreatingEmptyLinks: false,
54
+ addTargetToExternalLinks: false
55
+ });
56
+ }
57
+ /**
58
+ * @inheritDoc
59
+ */
60
+ init() {
61
+ const editor = this.editor;
62
+ const allowedProtocols = this.editor.config.get('link.allowedProtocols');
63
+ // Allow link attribute on all inline nodes.
64
+ editor.model.schema.extend('$text', { allowAttributes: 'linkHref' });
65
+ editor.conversion.for('dataDowncast')
66
+ .attributeToElement({ model: 'linkHref', view: createLinkElement });
67
+ editor.conversion.for('editingDowncast')
68
+ .attributeToElement({ model: 'linkHref', view: (href, conversionApi) => {
69
+ return createLinkElement(ensureSafeUrl(href, allowedProtocols), conversionApi);
70
+ } });
71
+ editor.conversion.for('upcast')
72
+ .elementToAttribute({
73
+ view: {
74
+ name: 'a',
75
+ attributes: {
76
+ href: true
77
+ }
78
+ },
79
+ model: {
80
+ key: 'linkHref',
81
+ value: (viewElement) => viewElement.getAttribute('href')
82
+ }
83
+ });
84
+ // Create linking commands.
85
+ editor.commands.add('link', new LinkCommand(editor));
86
+ editor.commands.add('unlink', new UnlinkCommand(editor));
87
+ const linkDecorators = getLocalizedDecorators(editor.t, normalizeDecorators(editor.config.get('link.decorators')));
88
+ this._enableAutomaticDecorators(linkDecorators
89
+ .filter((item) => item.mode === DECORATOR_AUTOMATIC));
90
+ this._enableManualDecorators(linkDecorators
91
+ .filter((item) => item.mode === DECORATOR_MANUAL));
92
+ // Enable two-step caret movement for `linkHref` attribute.
93
+ const twoStepCaretMovementPlugin = editor.plugins.get(TwoStepCaretMovement);
94
+ twoStepCaretMovementPlugin.registerAttribute('linkHref');
95
+ // Setup highlight over selected link.
96
+ inlineHighlight(editor, 'linkHref', 'a', HIGHLIGHT_CLASS);
97
+ // Handle link following by CTRL+click or ALT+ENTER
98
+ this._enableLinkOpen();
99
+ // Clears the DocumentSelection decorator attributes if the selection is no longer in a link (for example while using 2-SCM).
100
+ this._enableSelectionAttributesFixer();
101
+ // Handle adding default protocol to pasted links.
102
+ this._enableClipboardIntegration();
103
+ }
104
+ /**
105
+ * Processes an array of configured {@link module:link/linkconfig~LinkDecoratorAutomaticDefinition automatic decorators}
106
+ * and registers a {@link module:engine/conversion/downcastdispatcher~DowncastDispatcher downcast dispatcher}
107
+ * for each one of them. Downcast dispatchers are obtained using the
108
+ * {@link module:link/utils/automaticdecorators~AutomaticDecorators#getDispatcher} method.
109
+ *
110
+ * **Note**: This method also activates the automatic external link decorator if enabled with
111
+ * {@link module:link/linkconfig~LinkConfig#addTargetToExternalLinks `config.link.addTargetToExternalLinks`}.
112
+ */
113
+ _enableAutomaticDecorators(automaticDecoratorDefinitions) {
114
+ const editor = this.editor;
115
+ // Store automatic decorators in the command instance as we do the same with manual decorators.
116
+ // Thanks to that, `LinkImageEditing` plugin can re-use the same definitions.
117
+ const command = editor.commands.get('link');
118
+ const automaticDecorators = command.automaticDecorators;
119
+ // Adds a default decorator for external links.
120
+ if (editor.config.get('link.addTargetToExternalLinks')) {
121
+ automaticDecorators.add({
122
+ id: 'linkIsExternal',
123
+ mode: DECORATOR_AUTOMATIC,
124
+ callback: url => !!url && EXTERNAL_LINKS_REGEXP.test(url),
125
+ attributes: {
126
+ target: '_blank',
127
+ rel: 'noopener noreferrer'
128
+ }
129
+ });
130
+ }
131
+ automaticDecorators.add(automaticDecoratorDefinitions);
132
+ if (automaticDecorators.length) {
133
+ editor.conversion.for('downcast').add(automaticDecorators.getDispatcher());
134
+ }
135
+ }
136
+ /**
137
+ * Processes an array of configured {@link module:link/linkconfig~LinkDecoratorManualDefinition manual decorators},
138
+ * transforms them into {@link module:link/utils/manualdecorator~ManualDecorator} instances and stores them in the
139
+ * {@link module:link/linkcommand~LinkCommand#manualDecorators} collection (a model for manual decorators state).
140
+ *
141
+ * Also registers an {@link module:engine/conversion/downcasthelpers~DowncastHelpers#attributeToElement attribute-to-element}
142
+ * converter for each manual decorator and extends the {@link module:engine/model/schema~Schema model's schema}
143
+ * with adequate model attributes.
144
+ */
145
+ _enableManualDecorators(manualDecoratorDefinitions) {
146
+ if (!manualDecoratorDefinitions.length) {
147
+ return;
148
+ }
149
+ const editor = this.editor;
150
+ const command = editor.commands.get('link');
151
+ const manualDecorators = command.manualDecorators;
152
+ manualDecoratorDefinitions.forEach(decoratorDefinition => {
153
+ editor.model.schema.extend('$text', { allowAttributes: decoratorDefinition.id });
154
+ // Keeps reference to manual decorator to decode its name to attributes during downcast.
155
+ const decorator = new ManualDecorator(decoratorDefinition);
156
+ manualDecorators.add(decorator);
157
+ editor.conversion.for('downcast').attributeToElement({
158
+ model: decorator.id,
159
+ view: (manualDecoratorValue, { writer, schema }, { item }) => {
160
+ // Manual decorators for block links are handled e.g. in LinkImageEditing.
161
+ if (!(item.is('selection') || schema.isInline(item))) {
162
+ return;
163
+ }
164
+ if (manualDecoratorValue) {
165
+ const element = writer.createAttributeElement('a', decorator.attributes, { priority: 5 });
166
+ if (decorator.classes) {
167
+ writer.addClass(decorator.classes, element);
168
+ }
169
+ for (const key in decorator.styles) {
170
+ writer.setStyle(key, decorator.styles[key], element);
171
+ }
172
+ writer.setCustomProperty('link', true, element);
173
+ return element;
174
+ }
175
+ }
176
+ });
177
+ editor.conversion.for('upcast').elementToAttribute({
178
+ view: {
179
+ name: 'a',
180
+ ...decorator._createPattern()
181
+ },
182
+ model: {
183
+ key: decorator.id
184
+ }
185
+ });
186
+ });
187
+ }
188
+ /**
189
+ * Attaches handlers for {@link module:engine/view/document~Document#event:enter} and
190
+ * {@link module:engine/view/document~Document#event:click} to enable link following.
191
+ */
192
+ _enableLinkOpen() {
193
+ const editor = this.editor;
194
+ const view = editor.editing.view;
195
+ const viewDocument = view.document;
196
+ this.listenTo(viewDocument, 'click', (evt, data) => {
197
+ const shouldOpen = env.isMac ? data.domEvent.metaKey : data.domEvent.ctrlKey;
198
+ if (!shouldOpen) {
199
+ return;
200
+ }
201
+ let clickedElement = data.domTarget;
202
+ if (clickedElement.tagName.toLowerCase() != 'a') {
203
+ clickedElement = clickedElement.closest('a');
204
+ }
205
+ if (!clickedElement) {
206
+ return;
207
+ }
208
+ const url = clickedElement.getAttribute('href');
209
+ if (!url) {
210
+ return;
211
+ }
212
+ evt.stop();
213
+ data.preventDefault();
214
+ openLink(url);
215
+ }, { context: '$capture' });
216
+ // Open link on Alt+Enter.
217
+ this.listenTo(viewDocument, 'keydown', (evt, data) => {
218
+ const linkCommand = editor.commands.get('link');
219
+ const url = linkCommand.value;
220
+ const shouldOpen = !!url && data.keyCode === keyCodes.enter && data.altKey;
221
+ if (!shouldOpen) {
222
+ return;
223
+ }
224
+ evt.stop();
225
+ openLink(url);
226
+ });
227
+ }
228
+ /**
229
+ * Watches the DocumentSelection attribute changes and removes link decorator attributes when the linkHref attribute is removed.
230
+ *
231
+ * This is to ensure that there is no left-over link decorator attributes on the document selection that is no longer in a link.
232
+ */
233
+ _enableSelectionAttributesFixer() {
234
+ const editor = this.editor;
235
+ const model = editor.model;
236
+ const selection = model.document.selection;
237
+ this.listenTo(selection, 'change:attribute', (evt, { attributeKeys }) => {
238
+ if (!attributeKeys.includes('linkHref') || selection.hasAttribute('linkHref')) {
239
+ return;
240
+ }
241
+ model.change(writer => {
242
+ removeLinkAttributesFromSelection(writer, getLinkAttributesAllowedOnText(model.schema));
243
+ });
244
+ });
245
+ }
246
+ /**
247
+ * Enables URL fixing on pasting.
248
+ */
249
+ _enableClipboardIntegration() {
250
+ const editor = this.editor;
251
+ const model = editor.model;
252
+ const defaultProtocol = this.editor.config.get('link.defaultProtocol');
253
+ if (!defaultProtocol) {
254
+ return;
255
+ }
256
+ this.listenTo(editor.plugins.get('ClipboardPipeline'), 'contentInsertion', (evt, data) => {
257
+ model.change(writer => {
258
+ const range = writer.createRangeIn(data.content);
259
+ for (const item of range.getItems()) {
260
+ if (item.hasAttribute('linkHref')) {
261
+ const newLink = addLinkProtocolIfApplicable(item.getAttribute('linkHref'), defaultProtocol);
262
+ writer.setAttribute('linkHref', newLink, item);
263
+ }
264
+ }
265
+ });
266
+ });
267
+ }
268
+ }
269
+ /**
270
+ * Make the selection free of link-related model attributes.
271
+ * All link-related model attributes start with "link". That includes not only "linkHref"
272
+ * but also all decorator attributes (they have dynamic names), or even custom plugins.
273
+ */
274
+ function removeLinkAttributesFromSelection(writer, linkAttributes) {
275
+ writer.removeSelectionAttribute('linkHref');
276
+ for (const attribute of linkAttributes) {
277
+ writer.removeSelectionAttribute(attribute);
278
+ }
279
+ }
280
+ /**
281
+ * Returns an array containing names of the attributes allowed on `$text` that describes the link item.
282
+ */
283
+ function getLinkAttributesAllowedOnText(schema) {
284
+ const textAttributes = schema.getDefinition('$text').allowAttributes;
285
+ return textAttributes.filter(attribute => attribute.startsWith('link'));
286
+ }
@@ -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/linkimage
7
+ */
8
+ import { Plugin } from 'ckeditor5/src/core.js';
9
+ import LinkImageEditing from './linkimageediting.js';
10
+ import LinkImageUI from './linkimageui.js';
11
+ import '../theme/linkimage.css';
12
+ /**
13
+ * The `LinkImage` plugin.
14
+ *
15
+ * This is a "glue" plugin that loads the {@link module:link/linkimageediting~LinkImageEditing link image editing feature}
16
+ * and {@link module:link/linkimageui~LinkImageUI link image UI feature}.
17
+ */
18
+ export default class LinkImage extends Plugin {
19
+ /**
20
+ * @inheritDoc
21
+ */
22
+ static get requires(): readonly [typeof LinkImageEditing, typeof LinkImageUI];
23
+ /**
24
+ * @inheritDoc
25
+ */
26
+ static get pluginName(): "LinkImage";
27
+ /**
28
+ * @inheritDoc
29
+ */
30
+ static get isOfficialPlugin(): true;
31
+ }