@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,31 @@
1
+ /**
2
+ * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
3
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
+ */
5
+ /**
6
+ * @module link/unlinkcommand
7
+ */
8
+ import { Command } from 'ckeditor5/src/core.js';
9
+ /**
10
+ * The unlink command. It is used by the {@link module:link/link~Link link plugin}.
11
+ */
12
+ export default class UnlinkCommand extends Command {
13
+ /**
14
+ * @inheritDoc
15
+ */
16
+ refresh(): void;
17
+ /**
18
+ * Executes the command.
19
+ *
20
+ * When the selection is collapsed, it removes the `linkHref` attribute from each node with the same `linkHref` attribute value.
21
+ * When the selection is non-collapsed, it removes the `linkHref` attribute from each node in selected ranges.
22
+ *
23
+ * # Decorators
24
+ *
25
+ * If {@link module:link/linkconfig~LinkConfig#decorators `config.link.decorators`} is specified,
26
+ * all configured decorators are removed together with the `linkHref` attribute.
27
+ *
28
+ * @fires execute
29
+ */
30
+ execute(): void;
31
+ }
@@ -0,0 +1,66 @@
1
+ /**
2
+ * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
3
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
+ */
5
+ /**
6
+ * @module link/unlinkcommand
7
+ */
8
+ import { Command } from 'ckeditor5/src/core.js';
9
+ import { findAttributeRange } from 'ckeditor5/src/typing.js';
10
+ import { isLinkableElement } from './utils.js';
11
+ /**
12
+ * The unlink command. It is used by the {@link module:link/link~Link link plugin}.
13
+ */
14
+ export default class UnlinkCommand extends Command {
15
+ /**
16
+ * @inheritDoc
17
+ */
18
+ refresh() {
19
+ const model = this.editor.model;
20
+ const selection = model.document.selection;
21
+ const selectedElement = selection.getSelectedElement();
22
+ // A check for any integration that allows linking elements (e.g. `LinkImage`).
23
+ // Currently the selection reads attributes from text nodes only. See #7429 and #7465.
24
+ if (isLinkableElement(selectedElement, model.schema)) {
25
+ this.isEnabled = model.schema.checkAttribute(selectedElement, 'linkHref');
26
+ }
27
+ else {
28
+ this.isEnabled = model.schema.checkAttributeInSelection(selection, 'linkHref');
29
+ }
30
+ }
31
+ /**
32
+ * Executes the command.
33
+ *
34
+ * When the selection is collapsed, it removes the `linkHref` attribute from each node with the same `linkHref` attribute value.
35
+ * When the selection is non-collapsed, it removes the `linkHref` attribute from each node in selected ranges.
36
+ *
37
+ * # Decorators
38
+ *
39
+ * If {@link module:link/linkconfig~LinkConfig#decorators `config.link.decorators`} is specified,
40
+ * all configured decorators are removed together with the `linkHref` attribute.
41
+ *
42
+ * @fires execute
43
+ */
44
+ execute() {
45
+ const editor = this.editor;
46
+ const model = this.editor.model;
47
+ const selection = model.document.selection;
48
+ const linkCommand = editor.commands.get('link');
49
+ model.change(writer => {
50
+ // Get ranges to unlink.
51
+ const rangesToUnlink = selection.isCollapsed ?
52
+ [findAttributeRange(selection.getFirstPosition(), 'linkHref', selection.getAttribute('linkHref'), model)] :
53
+ model.schema.getValidRanges(selection.getRanges(), 'linkHref');
54
+ // Remove `linkHref` attribute from specified ranges.
55
+ for (const range of rangesToUnlink) {
56
+ writer.removeAttribute('linkHref', range);
57
+ // If there are registered custom attributes, then remove them during unlink.
58
+ if (linkCommand) {
59
+ for (const manualDecorator of linkCommand.manualDecorators) {
60
+ writer.removeAttribute(manualDecorator.id, range);
61
+ }
62
+ }
63
+ }
64
+ });
65
+ }
66
+ }
@@ -0,0 +1,45 @@
1
+ /**
2
+ * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
3
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
+ */
5
+ /**
6
+ * @module link/utils/automaticdecorators
7
+ */
8
+ import { type ArrayOrItem } from 'ckeditor5/src/utils.js';
9
+ import type { DowncastDispatcher } from 'ckeditor5/src/engine.js';
10
+ import type { NormalizedLinkDecoratorAutomaticDefinition } from '../utils.js';
11
+ /**
12
+ * Helper class that ties together all {@link module:link/linkconfig~LinkDecoratorAutomaticDefinition} and provides
13
+ * the {@link module:engine/conversion/downcasthelpers~DowncastHelpers#attributeToElement downcast dispatchers} for them.
14
+ */
15
+ export default class AutomaticDecorators {
16
+ /**
17
+ * Stores the definition of {@link module:link/linkconfig~LinkDecoratorAutomaticDefinition automatic decorators}.
18
+ * This data is used as a source for a downcast dispatcher to create a proper conversion to output data.
19
+ */
20
+ private _definitions;
21
+ /**
22
+ * Gives information about the number of decorators stored in the {@link module:link/utils/automaticdecorators~AutomaticDecorators}
23
+ * instance.
24
+ */
25
+ get length(): number;
26
+ /**
27
+ * Adds automatic decorator objects or an array with them to be used during downcasting.
28
+ *
29
+ * @param item A configuration object of automatic rules for decorating links. It might also be an array of such objects.
30
+ */
31
+ add(item: ArrayOrItem<NormalizedLinkDecoratorAutomaticDefinition>): void;
32
+ /**
33
+ * Provides the conversion helper used in the {@link module:engine/conversion/downcasthelpers~DowncastHelpers#add} method.
34
+ *
35
+ * @returns A dispatcher function used as conversion helper in {@link module:engine/conversion/downcasthelpers~DowncastHelpers#add}.
36
+ */
37
+ getDispatcher(): (dispatcher: DowncastDispatcher) => void;
38
+ /**
39
+ * Provides the conversion helper used in the {@link module:engine/conversion/downcasthelpers~DowncastHelpers#add} method
40
+ * when linking images.
41
+ *
42
+ * @returns A dispatcher function used as conversion helper in {@link module:engine/conversion/downcasthelpers~DowncastHelpers#add}.
43
+ */
44
+ getDispatcherForLinkedImage(): (dispatcher: DowncastDispatcher) => void;
45
+ }
@@ -0,0 +1,140 @@
1
+ /**
2
+ * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
3
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
+ */
5
+ /**
6
+ * @module link/utils/automaticdecorators
7
+ */
8
+ import { toMap } from 'ckeditor5/src/utils.js';
9
+ /**
10
+ * Helper class that ties together all {@link module:link/linkconfig~LinkDecoratorAutomaticDefinition} and provides
11
+ * the {@link module:engine/conversion/downcasthelpers~DowncastHelpers#attributeToElement downcast dispatchers} for them.
12
+ */
13
+ export default class AutomaticDecorators {
14
+ constructor() {
15
+ /**
16
+ * Stores the definition of {@link module:link/linkconfig~LinkDecoratorAutomaticDefinition automatic decorators}.
17
+ * This data is used as a source for a downcast dispatcher to create a proper conversion to output data.
18
+ */
19
+ this._definitions = new Set();
20
+ }
21
+ /**
22
+ * Gives information about the number of decorators stored in the {@link module:link/utils/automaticdecorators~AutomaticDecorators}
23
+ * instance.
24
+ */
25
+ get length() {
26
+ return this._definitions.size;
27
+ }
28
+ /**
29
+ * Adds automatic decorator objects or an array with them to be used during downcasting.
30
+ *
31
+ * @param item A configuration object of automatic rules for decorating links. It might also be an array of such objects.
32
+ */
33
+ add(item) {
34
+ if (Array.isArray(item)) {
35
+ item.forEach(item => this._definitions.add(item));
36
+ }
37
+ else {
38
+ this._definitions.add(item);
39
+ }
40
+ }
41
+ /**
42
+ * Provides the conversion helper used in the {@link module:engine/conversion/downcasthelpers~DowncastHelpers#add} method.
43
+ *
44
+ * @returns A dispatcher function used as conversion helper in {@link module:engine/conversion/downcasthelpers~DowncastHelpers#add}.
45
+ */
46
+ getDispatcher() {
47
+ return dispatcher => {
48
+ dispatcher.on('attribute:linkHref', (evt, data, conversionApi) => {
49
+ // There is only test as this behavior decorates links and
50
+ // it is run before dispatcher which actually consumes this node.
51
+ // This allows on writing own dispatcher with highest priority,
52
+ // which blocks both native converter and this additional decoration.
53
+ if (!conversionApi.consumable.test(data.item, 'attribute:linkHref')) {
54
+ return;
55
+ }
56
+ // Automatic decorators for block links are handled e.g. in LinkImageEditing.
57
+ if (!(data.item.is('selection') || conversionApi.schema.isInline(data.item))) {
58
+ return;
59
+ }
60
+ const viewWriter = conversionApi.writer;
61
+ const viewSelection = viewWriter.document.selection;
62
+ for (const item of this._definitions) {
63
+ const viewElement = viewWriter.createAttributeElement('a', item.attributes, {
64
+ priority: 5
65
+ });
66
+ if (item.classes) {
67
+ viewWriter.addClass(item.classes, viewElement);
68
+ }
69
+ for (const key in item.styles) {
70
+ viewWriter.setStyle(key, item.styles[key], viewElement);
71
+ }
72
+ viewWriter.setCustomProperty('link', true, viewElement);
73
+ if (item.callback(data.attributeNewValue)) {
74
+ if (data.item.is('selection')) {
75
+ viewWriter.wrap(viewSelection.getFirstRange(), viewElement);
76
+ }
77
+ else {
78
+ viewWriter.wrap(conversionApi.mapper.toViewRange(data.range), viewElement);
79
+ }
80
+ }
81
+ else {
82
+ viewWriter.unwrap(conversionApi.mapper.toViewRange(data.range), viewElement);
83
+ }
84
+ }
85
+ }, { priority: 'high' });
86
+ };
87
+ }
88
+ /**
89
+ * Provides the conversion helper used in the {@link module:engine/conversion/downcasthelpers~DowncastHelpers#add} method
90
+ * when linking images.
91
+ *
92
+ * @returns A dispatcher function used as conversion helper in {@link module:engine/conversion/downcasthelpers~DowncastHelpers#add}.
93
+ */
94
+ getDispatcherForLinkedImage() {
95
+ return dispatcher => {
96
+ dispatcher.on('attribute:linkHref:imageBlock', (evt, data, { writer, mapper }) => {
97
+ const viewFigure = mapper.toViewElement(data.item);
98
+ const linkInImage = Array.from(viewFigure.getChildren())
99
+ .find((child) => child.is('element', 'a'));
100
+ for (const item of this._definitions) {
101
+ const attributes = toMap(item.attributes);
102
+ if (item.callback(data.attributeNewValue)) {
103
+ for (const [key, val] of attributes) {
104
+ // Left for backward compatibility. Since v30 decorator should
105
+ // accept `classes` and `styles` separately from `attributes`.
106
+ if (key === 'class') {
107
+ writer.addClass(val, linkInImage);
108
+ }
109
+ else {
110
+ writer.setAttribute(key, val, linkInImage);
111
+ }
112
+ }
113
+ if (item.classes) {
114
+ writer.addClass(item.classes, linkInImage);
115
+ }
116
+ for (const key in item.styles) {
117
+ writer.setStyle(key, item.styles[key], linkInImage);
118
+ }
119
+ }
120
+ else {
121
+ for (const [key, val] of attributes) {
122
+ if (key === 'class') {
123
+ writer.removeClass(val, linkInImage);
124
+ }
125
+ else {
126
+ writer.removeAttribute(key, linkInImage);
127
+ }
128
+ }
129
+ if (item.classes) {
130
+ writer.removeClass(item.classes, linkInImage);
131
+ }
132
+ for (const key in item.styles) {
133
+ writer.removeStyle(key, linkInImage);
134
+ }
135
+ }
136
+ }
137
+ });
138
+ };
139
+ }
140
+ }
@@ -0,0 +1,72 @@
1
+ /**
2
+ * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
3
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
+ */
5
+ /**
6
+ * @module link/utils/manualdecorator
7
+ */
8
+ import { type ArrayOrItem } from 'ckeditor5/src/utils.js';
9
+ import type { MatcherObjectPattern } from 'ckeditor5/src/engine.js';
10
+ import type { NormalizedLinkDecoratorManualDefinition } from '../utils.js';
11
+ declare const ManualDecorator_base: {
12
+ new (): import("ckeditor5/src/utils.js").Observable;
13
+ prototype: import("ckeditor5/src/utils.js").Observable;
14
+ };
15
+ /**
16
+ * Helper class that stores manual decorators with observable {@link module:link/utils/manualdecorator~ManualDecorator#value}
17
+ * to support integration with the UI state. An instance of this class is a model with the state of individual manual decorators.
18
+ * These decorators are kept as collections in {@link module:link/linkcommand~LinkCommand#manualDecorators}.
19
+ */
20
+ export default class ManualDecorator extends /* #__PURE__ */ ManualDecorator_base {
21
+ /**
22
+ * An ID of a manual decorator which is the name of the attribute in the model, for example: 'linkManualDecorator0'.
23
+ */
24
+ id: string;
25
+ /**
26
+ * The value of the current manual decorator. It reflects its state from the UI.
27
+ *
28
+ * @observable
29
+ */
30
+ value: boolean | undefined;
31
+ /**
32
+ * The default value of manual decorator.
33
+ */
34
+ defaultValue?: boolean;
35
+ /**
36
+ * The label used in the user interface to toggle the manual decorator.
37
+ */
38
+ label: string;
39
+ /**
40
+ * A set of attributes added to downcasted data when the decorator is activated for a specific link.
41
+ * Attributes should be added in a form of attributes defined in {@link module:engine/view/elementdefinition~ElementDefinition}.
42
+ */
43
+ attributes?: Record<string, string>;
44
+ /**
45
+ * A set of classes added to downcasted data when the decorator is activated for a specific link.
46
+ * Classes should be added in a form of classes defined in {@link module:engine/view/elementdefinition~ElementDefinition}.
47
+ */
48
+ classes?: ArrayOrItem<string>;
49
+ /**
50
+ * A set of styles added to downcasted data when the decorator is activated for a specific link.
51
+ * Styles should be added in a form of styles defined in {@link module:engine/view/elementdefinition~ElementDefinition}.
52
+ */
53
+ styles?: Record<string, string>;
54
+ /**
55
+ * Creates a new instance of {@link module:link/utils/manualdecorator~ManualDecorator}.
56
+ *
57
+ * @param config.id The name of the attribute used in the model that represents a given manual decorator.
58
+ * For example: `'linkIsExternal'`.
59
+ * @param config.label The label used in the user interface to toggle the manual decorator.
60
+ * @param config.attributes A set of attributes added to output data when the decorator is active for a specific link.
61
+ * Attributes should keep the format of attributes defined in {@link module:engine/view/elementdefinition~ElementDefinition}.
62
+ * @param [config.defaultValue] Controls whether the decorator is "on" by default.
63
+ */
64
+ constructor({ id, label, attributes, classes, styles, defaultValue }: NormalizedLinkDecoratorManualDefinition);
65
+ /**
66
+ * Returns {@link module:engine/view/matcher~MatcherPattern} with decorator attributes.
67
+ *
68
+ * @internal
69
+ */
70
+ _createPattern(): MatcherObjectPattern;
71
+ }
72
+ export {};
@@ -0,0 +1,47 @@
1
+ /**
2
+ * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
3
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
+ */
5
+ /**
6
+ * @module link/utils/manualdecorator
7
+ */
8
+ import { ObservableMixin } from 'ckeditor5/src/utils.js';
9
+ /**
10
+ * Helper class that stores manual decorators with observable {@link module:link/utils/manualdecorator~ManualDecorator#value}
11
+ * to support integration with the UI state. An instance of this class is a model with the state of individual manual decorators.
12
+ * These decorators are kept as collections in {@link module:link/linkcommand~LinkCommand#manualDecorators}.
13
+ */
14
+ export default class ManualDecorator extends /* #__PURE__ */ ObservableMixin() {
15
+ /**
16
+ * Creates a new instance of {@link module:link/utils/manualdecorator~ManualDecorator}.
17
+ *
18
+ * @param config.id The name of the attribute used in the model that represents a given manual decorator.
19
+ * For example: `'linkIsExternal'`.
20
+ * @param config.label The label used in the user interface to toggle the manual decorator.
21
+ * @param config.attributes A set of attributes added to output data when the decorator is active for a specific link.
22
+ * Attributes should keep the format of attributes defined in {@link module:engine/view/elementdefinition~ElementDefinition}.
23
+ * @param [config.defaultValue] Controls whether the decorator is "on" by default.
24
+ */
25
+ constructor({ id, label, attributes, classes, styles, defaultValue }) {
26
+ super();
27
+ this.id = id;
28
+ this.set('value', undefined);
29
+ this.defaultValue = defaultValue;
30
+ this.label = label;
31
+ this.attributes = attributes;
32
+ this.classes = classes;
33
+ this.styles = styles;
34
+ }
35
+ /**
36
+ * Returns {@link module:engine/view/matcher~MatcherPattern} with decorator attributes.
37
+ *
38
+ * @internal
39
+ */
40
+ _createPattern() {
41
+ return {
42
+ attributes: this.attributes,
43
+ classes: this.classes,
44
+ styles: this.styles
45
+ };
46
+ }
47
+ }
package/src/utils.d.ts ADDED
@@ -0,0 +1,80 @@
1
+ /**
2
+ * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
3
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
+ */
5
+ /**
6
+ * @module link/utils
7
+ */
8
+ import type { DowncastConversionApi, Element, Schema, ViewAttributeElement, ViewNode, ViewDocumentFragment } from 'ckeditor5/src/engine.js';
9
+ import type { LocaleTranslate } from 'ckeditor5/src/utils.js';
10
+ import type { LinkDecoratorAutomaticDefinition, LinkDecoratorDefinition, LinkDecoratorManualDefinition } from './linkconfig.js';
11
+ /**
12
+ * A keystroke used by the {@link module:link/linkui~LinkUI link UI feature}.
13
+ */
14
+ export declare const LINK_KEYSTROKE = "Ctrl+K";
15
+ /**
16
+ * Returns `true` if a given view node is the link element.
17
+ */
18
+ export declare function isLinkElement(node: ViewNode | ViewDocumentFragment): boolean;
19
+ /**
20
+ * Creates a link {@link module:engine/view/attributeelement~AttributeElement} with the provided `href` attribute.
21
+ */
22
+ export declare function createLinkElement(href: string, { writer }: DowncastConversionApi): ViewAttributeElement;
23
+ /**
24
+ * Returns a safe URL based on a given value.
25
+ *
26
+ * A URL is considered safe if it is safe for the user (does not contain any malicious code).
27
+ *
28
+ * If a URL is considered unsafe, a simple `"#"` is returned.
29
+ *
30
+ * @internal
31
+ */
32
+ export declare function ensureSafeUrl(url: unknown, allowedProtocols?: Array<string>): string;
33
+ /**
34
+ * Returns the {@link module:link/linkconfig~LinkConfig#decorators `config.link.decorators`} configuration processed
35
+ * to respect the locale of the editor, i.e. to display the {@link module:link/linkconfig~LinkDecoratorManualDefinition label}
36
+ * in the correct language.
37
+ *
38
+ * **Note**: Only the few most commonly used labels are translated automatically. Other labels should be manually
39
+ * translated in the {@link module:link/linkconfig~LinkConfig#decorators `config.link.decorators`} configuration.
40
+ *
41
+ * @param t Shorthand for {@link module:utils/locale~Locale#t Locale#t}.
42
+ * @param decorators The decorator reference where the label values should be localized.
43
+ */
44
+ export declare function getLocalizedDecorators(t: LocaleTranslate, decorators: Array<NormalizedLinkDecoratorDefinition>): Array<NormalizedLinkDecoratorDefinition>;
45
+ /**
46
+ * Converts an object with defined decorators to a normalized array of decorators. The `id` key is added for each decorator and
47
+ * is used as the attribute's name in the model.
48
+ */
49
+ export declare function normalizeDecorators(decorators?: Record<string, LinkDecoratorDefinition>): Array<NormalizedLinkDecoratorDefinition>;
50
+ /**
51
+ * Returns `true` if the specified `element` can be linked (the element allows the `linkHref` attribute).
52
+ */
53
+ export declare function isLinkableElement(element: Element | null, schema: Schema): element is Element;
54
+ /**
55
+ * Returns `true` if the specified `value` is an email.
56
+ */
57
+ export declare function isEmail(value: string): boolean;
58
+ /**
59
+ * Adds the protocol prefix to the specified `link` when:
60
+ *
61
+ * * it does not contain it already, and there is a {@link module:link/linkconfig~LinkConfig#defaultProtocol `defaultProtocol` }
62
+ * configuration value provided,
63
+ * * or the link is an email address.
64
+ */
65
+ export declare function addLinkProtocolIfApplicable(link: string, defaultProtocol?: string): string;
66
+ /**
67
+ * Checks if protocol is already included in the link.
68
+ */
69
+ export declare function linkHasProtocol(link: string): boolean;
70
+ /**
71
+ * Opens the link in a new browser tab.
72
+ */
73
+ export declare function openLink(link: string): void;
74
+ export type NormalizedLinkDecoratorAutomaticDefinition = LinkDecoratorAutomaticDefinition & {
75
+ id: string;
76
+ };
77
+ export type NormalizedLinkDecoratorManualDefinition = LinkDecoratorManualDefinition & {
78
+ id: string;
79
+ };
80
+ export type NormalizedLinkDecoratorDefinition = NormalizedLinkDecoratorAutomaticDefinition | NormalizedLinkDecoratorManualDefinition;
package/src/utils.js ADDED
@@ -0,0 +1,135 @@
1
+ /**
2
+ * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
3
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
+ */
5
+ import { upperFirst } from 'lodash-es';
6
+ const ATTRIBUTE_WHITESPACES = /[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205f\u3000]/g; // eslint-disable-line no-control-regex
7
+ const SAFE_URL_TEMPLATE = '^(?:(?:<protocols>):|[^a-z]|[a-z+.-]+(?:[^a-z+.:-]|$))';
8
+ // Simplified email test - should be run over previously found URL.
9
+ const EMAIL_REG_EXP = /^[\S]+@((?![-_])(?:[-\w\u00a1-\uffff]{0,63}[^-_]\.))+(?:[a-z\u00a1-\uffff]{2,})$/i;
10
+ // The regex checks for the protocol syntax ('xxxx://' or 'xxxx:')
11
+ // or non-word characters at the beginning of the link ('/', '#' etc.).
12
+ const PROTOCOL_REG_EXP = /^((\w+:(\/{2,})?)|(\W))/i;
13
+ const DEFAULT_LINK_PROTOCOLS = [
14
+ 'https?',
15
+ 'ftps?',
16
+ 'mailto'
17
+ ];
18
+ /**
19
+ * A keystroke used by the {@link module:link/linkui~LinkUI link UI feature}.
20
+ */
21
+ export const LINK_KEYSTROKE = 'Ctrl+K';
22
+ /**
23
+ * Returns `true` if a given view node is the link element.
24
+ */
25
+ export function isLinkElement(node) {
26
+ return node.is('attributeElement') && !!node.getCustomProperty('link');
27
+ }
28
+ /**
29
+ * Creates a link {@link module:engine/view/attributeelement~AttributeElement} with the provided `href` attribute.
30
+ */
31
+ export function createLinkElement(href, { writer }) {
32
+ // Priority 5 - https://github.com/ckeditor/ckeditor5-link/issues/121.
33
+ const linkElement = writer.createAttributeElement('a', { href }, { priority: 5 });
34
+ writer.setCustomProperty('link', true, linkElement);
35
+ return linkElement;
36
+ }
37
+ /**
38
+ * Returns a safe URL based on a given value.
39
+ *
40
+ * A URL is considered safe if it is safe for the user (does not contain any malicious code).
41
+ *
42
+ * If a URL is considered unsafe, a simple `"#"` is returned.
43
+ *
44
+ * @internal
45
+ */
46
+ export function ensureSafeUrl(url, allowedProtocols = DEFAULT_LINK_PROTOCOLS) {
47
+ const urlString = String(url);
48
+ const protocolsList = allowedProtocols.join('|');
49
+ const customSafeRegex = new RegExp(`${SAFE_URL_TEMPLATE.replace('<protocols>', protocolsList)}`, 'i');
50
+ return isSafeUrl(urlString, customSafeRegex) ? urlString : '#';
51
+ }
52
+ /**
53
+ * Checks whether the given URL is safe for the user (does not contain any malicious code).
54
+ */
55
+ function isSafeUrl(url, customRegexp) {
56
+ const normalizedUrl = url.replace(ATTRIBUTE_WHITESPACES, '');
57
+ return !!normalizedUrl.match(customRegexp);
58
+ }
59
+ /**
60
+ * Returns the {@link module:link/linkconfig~LinkConfig#decorators `config.link.decorators`} configuration processed
61
+ * to respect the locale of the editor, i.e. to display the {@link module:link/linkconfig~LinkDecoratorManualDefinition label}
62
+ * in the correct language.
63
+ *
64
+ * **Note**: Only the few most commonly used labels are translated automatically. Other labels should be manually
65
+ * translated in the {@link module:link/linkconfig~LinkConfig#decorators `config.link.decorators`} configuration.
66
+ *
67
+ * @param t Shorthand for {@link module:utils/locale~Locale#t Locale#t}.
68
+ * @param decorators The decorator reference where the label values should be localized.
69
+ */
70
+ export function getLocalizedDecorators(t, decorators) {
71
+ const localizedDecoratorsLabels = {
72
+ 'Open in a new tab': t('Open in a new tab'),
73
+ 'Downloadable': t('Downloadable')
74
+ };
75
+ decorators.forEach(decorator => {
76
+ if ('label' in decorator && localizedDecoratorsLabels[decorator.label]) {
77
+ decorator.label = localizedDecoratorsLabels[decorator.label];
78
+ }
79
+ return decorator;
80
+ });
81
+ return decorators;
82
+ }
83
+ /**
84
+ * Converts an object with defined decorators to a normalized array of decorators. The `id` key is added for each decorator and
85
+ * is used as the attribute's name in the model.
86
+ */
87
+ export function normalizeDecorators(decorators) {
88
+ const retArray = [];
89
+ if (decorators) {
90
+ for (const [key, value] of Object.entries(decorators)) {
91
+ const decorator = Object.assign({}, value, { id: `link${upperFirst(key)}` });
92
+ retArray.push(decorator);
93
+ }
94
+ }
95
+ return retArray;
96
+ }
97
+ /**
98
+ * Returns `true` if the specified `element` can be linked (the element allows the `linkHref` attribute).
99
+ */
100
+ export function isLinkableElement(element, schema) {
101
+ if (!element) {
102
+ return false;
103
+ }
104
+ return schema.checkAttribute(element.name, 'linkHref');
105
+ }
106
+ /**
107
+ * Returns `true` if the specified `value` is an email.
108
+ */
109
+ export function isEmail(value) {
110
+ return EMAIL_REG_EXP.test(value);
111
+ }
112
+ /**
113
+ * Adds the protocol prefix to the specified `link` when:
114
+ *
115
+ * * it does not contain it already, and there is a {@link module:link/linkconfig~LinkConfig#defaultProtocol `defaultProtocol` }
116
+ * configuration value provided,
117
+ * * or the link is an email address.
118
+ */
119
+ export function addLinkProtocolIfApplicable(link, defaultProtocol) {
120
+ const protocol = isEmail(link) ? 'mailto:' : defaultProtocol;
121
+ const isProtocolNeeded = !!protocol && !linkHasProtocol(link);
122
+ return link && isProtocolNeeded ? protocol + link : link;
123
+ }
124
+ /**
125
+ * Checks if protocol is already included in the link.
126
+ */
127
+ export function linkHasProtocol(link) {
128
+ return PROTOCOL_REG_EXP.test(link);
129
+ }
130
+ /**
131
+ * Opens the link in a new browser tab.
132
+ */
133
+ export function openLink(link) {
134
+ window.open(link, '_blank', 'noopener');
135
+ }
@@ -0,0 +1 @@
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>
@@ -0,0 +1 @@
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>
package/theme/link.css ADDED
@@ -0,0 +1,10 @@
1
+ /*
2
+ * 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
+ /*
7
+ * Note: This file should contain the wireframe styles only. But since there are no such styles,
8
+ * it acts as a message to the builder telling that it should look for the corresponding styles
9
+ * **in the theme** when compiling the editor.
10
+ */
@@ -0,0 +1,32 @@
1
+ /*
2
+ * 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
+ @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
+ }