@ckeditor/ckeditor5-indent 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 (309) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/LICENSE.md +17 -0
  3. package/README.md +26 -0
  4. package/build/indent.js +5 -0
  5. package/build/translations/ar.js +1 -0
  6. package/build/translations/az.js +1 -0
  7. package/build/translations/bg.js +1 -0
  8. package/build/translations/bn.js +1 -0
  9. package/build/translations/ca.js +1 -0
  10. package/build/translations/cs.js +1 -0
  11. package/build/translations/da.js +1 -0
  12. package/build/translations/de-ch.js +1 -0
  13. package/build/translations/de.js +1 -0
  14. package/build/translations/el.js +1 -0
  15. package/build/translations/en-au.js +1 -0
  16. package/build/translations/en-gb.js +1 -0
  17. package/build/translations/es.js +1 -0
  18. package/build/translations/et.js +1 -0
  19. package/build/translations/fa.js +1 -0
  20. package/build/translations/fi.js +1 -0
  21. package/build/translations/fr.js +1 -0
  22. package/build/translations/gl.js +1 -0
  23. package/build/translations/he.js +1 -0
  24. package/build/translations/hi.js +1 -0
  25. package/build/translations/hr.js +1 -0
  26. package/build/translations/hu.js +1 -0
  27. package/build/translations/id.js +1 -0
  28. package/build/translations/it.js +1 -0
  29. package/build/translations/ja.js +1 -0
  30. package/build/translations/ko.js +1 -0
  31. package/build/translations/ku.js +1 -0
  32. package/build/translations/lt.js +1 -0
  33. package/build/translations/lv.js +1 -0
  34. package/build/translations/ms.js +1 -0
  35. package/build/translations/ne.js +1 -0
  36. package/build/translations/nl.js +1 -0
  37. package/build/translations/no.js +1 -0
  38. package/build/translations/pl.js +1 -0
  39. package/build/translations/pt-br.js +1 -0
  40. package/build/translations/pt.js +1 -0
  41. package/build/translations/ro.js +1 -0
  42. package/build/translations/ru.js +1 -0
  43. package/build/translations/sk.js +1 -0
  44. package/build/translations/sr-latn.js +1 -0
  45. package/build/translations/sr.js +1 -0
  46. package/build/translations/sv.js +1 -0
  47. package/build/translations/th.js +1 -0
  48. package/build/translations/tk.js +1 -0
  49. package/build/translations/tr.js +1 -0
  50. package/build/translations/ug.js +1 -0
  51. package/build/translations/uk.js +1 -0
  52. package/build/translations/ur.js +1 -0
  53. package/build/translations/uz.js +1 -0
  54. package/build/translations/vi.js +1 -0
  55. package/build/translations/zh-cn.js +1 -0
  56. package/build/translations/zh.js +1 -0
  57. package/ckeditor5-metadata.json +49 -0
  58. package/dist/augmentation.d.ts +28 -0
  59. package/dist/indent.d.ts +48 -0
  60. package/dist/indentblock.d.ts +50 -0
  61. package/dist/indentblockcommand.d.ts +60 -0
  62. package/dist/indentcommandbehavior/indentbehavior.d.ts +29 -0
  63. package/dist/indentcommandbehavior/indentusingclasses.d.ts +43 -0
  64. package/dist/indentcommandbehavior/indentusingoffset.d.ts +49 -0
  65. package/dist/indentconfig.d.ts +76 -0
  66. package/dist/indentediting.d.ts +34 -0
  67. package/dist/indentui.d.ts +39 -0
  68. package/dist/index-content.css +4 -0
  69. package/dist/index-editor.css +4 -0
  70. package/dist/index.css +4 -0
  71. package/dist/index.d.ts +18 -0
  72. package/dist/index.js +466 -0
  73. package/dist/index.js.map +1 -0
  74. package/dist/translations/ar.d.ts +8 -0
  75. package/dist/translations/ar.js +5 -0
  76. package/dist/translations/ar.umd.js +11 -0
  77. package/dist/translations/az.d.ts +8 -0
  78. package/dist/translations/az.js +5 -0
  79. package/dist/translations/az.umd.js +11 -0
  80. package/dist/translations/bg.d.ts +8 -0
  81. package/dist/translations/bg.js +5 -0
  82. package/dist/translations/bg.umd.js +11 -0
  83. package/dist/translations/bn.d.ts +8 -0
  84. package/dist/translations/bn.js +5 -0
  85. package/dist/translations/bn.umd.js +11 -0
  86. package/dist/translations/ca.d.ts +8 -0
  87. package/dist/translations/ca.js +5 -0
  88. package/dist/translations/ca.umd.js +11 -0
  89. package/dist/translations/cs.d.ts +8 -0
  90. package/dist/translations/cs.js +5 -0
  91. package/dist/translations/cs.umd.js +11 -0
  92. package/dist/translations/da.d.ts +8 -0
  93. package/dist/translations/da.js +5 -0
  94. package/dist/translations/da.umd.js +11 -0
  95. package/dist/translations/de-ch.d.ts +8 -0
  96. package/dist/translations/de-ch.js +5 -0
  97. package/dist/translations/de-ch.umd.js +11 -0
  98. package/dist/translations/de.d.ts +8 -0
  99. package/dist/translations/de.js +5 -0
  100. package/dist/translations/de.umd.js +11 -0
  101. package/dist/translations/el.d.ts +8 -0
  102. package/dist/translations/el.js +5 -0
  103. package/dist/translations/el.umd.js +11 -0
  104. package/dist/translations/en-au.d.ts +8 -0
  105. package/dist/translations/en-au.js +5 -0
  106. package/dist/translations/en-au.umd.js +11 -0
  107. package/dist/translations/en-gb.d.ts +8 -0
  108. package/dist/translations/en-gb.js +5 -0
  109. package/dist/translations/en-gb.umd.js +11 -0
  110. package/dist/translations/en.d.ts +8 -0
  111. package/dist/translations/en.js +5 -0
  112. package/dist/translations/en.umd.js +11 -0
  113. package/dist/translations/es.d.ts +8 -0
  114. package/dist/translations/es.js +5 -0
  115. package/dist/translations/es.umd.js +11 -0
  116. package/dist/translations/et.d.ts +8 -0
  117. package/dist/translations/et.js +5 -0
  118. package/dist/translations/et.umd.js +11 -0
  119. package/dist/translations/fa.d.ts +8 -0
  120. package/dist/translations/fa.js +5 -0
  121. package/dist/translations/fa.umd.js +11 -0
  122. package/dist/translations/fi.d.ts +8 -0
  123. package/dist/translations/fi.js +5 -0
  124. package/dist/translations/fi.umd.js +11 -0
  125. package/dist/translations/fr.d.ts +8 -0
  126. package/dist/translations/fr.js +5 -0
  127. package/dist/translations/fr.umd.js +11 -0
  128. package/dist/translations/gl.d.ts +8 -0
  129. package/dist/translations/gl.js +5 -0
  130. package/dist/translations/gl.umd.js +11 -0
  131. package/dist/translations/he.d.ts +8 -0
  132. package/dist/translations/he.js +5 -0
  133. package/dist/translations/he.umd.js +11 -0
  134. package/dist/translations/hi.d.ts +8 -0
  135. package/dist/translations/hi.js +5 -0
  136. package/dist/translations/hi.umd.js +11 -0
  137. package/dist/translations/hr.d.ts +8 -0
  138. package/dist/translations/hr.js +5 -0
  139. package/dist/translations/hr.umd.js +11 -0
  140. package/dist/translations/hu.d.ts +8 -0
  141. package/dist/translations/hu.js +5 -0
  142. package/dist/translations/hu.umd.js +11 -0
  143. package/dist/translations/id.d.ts +8 -0
  144. package/dist/translations/id.js +5 -0
  145. package/dist/translations/id.umd.js +11 -0
  146. package/dist/translations/it.d.ts +8 -0
  147. package/dist/translations/it.js +5 -0
  148. package/dist/translations/it.umd.js +11 -0
  149. package/dist/translations/ja.d.ts +8 -0
  150. package/dist/translations/ja.js +5 -0
  151. package/dist/translations/ja.umd.js +11 -0
  152. package/dist/translations/ko.d.ts +8 -0
  153. package/dist/translations/ko.js +5 -0
  154. package/dist/translations/ko.umd.js +11 -0
  155. package/dist/translations/ku.d.ts +8 -0
  156. package/dist/translations/ku.js +5 -0
  157. package/dist/translations/ku.umd.js +11 -0
  158. package/dist/translations/lt.d.ts +8 -0
  159. package/dist/translations/lt.js +5 -0
  160. package/dist/translations/lt.umd.js +11 -0
  161. package/dist/translations/lv.d.ts +8 -0
  162. package/dist/translations/lv.js +5 -0
  163. package/dist/translations/lv.umd.js +11 -0
  164. package/dist/translations/ms.d.ts +8 -0
  165. package/dist/translations/ms.js +5 -0
  166. package/dist/translations/ms.umd.js +11 -0
  167. package/dist/translations/ne.d.ts +8 -0
  168. package/dist/translations/ne.js +5 -0
  169. package/dist/translations/ne.umd.js +11 -0
  170. package/dist/translations/nl.d.ts +8 -0
  171. package/dist/translations/nl.js +5 -0
  172. package/dist/translations/nl.umd.js +11 -0
  173. package/dist/translations/no.d.ts +8 -0
  174. package/dist/translations/no.js +5 -0
  175. package/dist/translations/no.umd.js +11 -0
  176. package/dist/translations/pl.d.ts +8 -0
  177. package/dist/translations/pl.js +5 -0
  178. package/dist/translations/pl.umd.js +11 -0
  179. package/dist/translations/pt-br.d.ts +8 -0
  180. package/dist/translations/pt-br.js +5 -0
  181. package/dist/translations/pt-br.umd.js +11 -0
  182. package/dist/translations/pt.d.ts +8 -0
  183. package/dist/translations/pt.js +5 -0
  184. package/dist/translations/pt.umd.js +11 -0
  185. package/dist/translations/ro.d.ts +8 -0
  186. package/dist/translations/ro.js +5 -0
  187. package/dist/translations/ro.umd.js +11 -0
  188. package/dist/translations/ru.d.ts +8 -0
  189. package/dist/translations/ru.js +5 -0
  190. package/dist/translations/ru.umd.js +11 -0
  191. package/dist/translations/sk.d.ts +8 -0
  192. package/dist/translations/sk.js +5 -0
  193. package/dist/translations/sk.umd.js +11 -0
  194. package/dist/translations/sr-latn.d.ts +8 -0
  195. package/dist/translations/sr-latn.js +5 -0
  196. package/dist/translations/sr-latn.umd.js +11 -0
  197. package/dist/translations/sr.d.ts +8 -0
  198. package/dist/translations/sr.js +5 -0
  199. package/dist/translations/sr.umd.js +11 -0
  200. package/dist/translations/sv.d.ts +8 -0
  201. package/dist/translations/sv.js +5 -0
  202. package/dist/translations/sv.umd.js +11 -0
  203. package/dist/translations/th.d.ts +8 -0
  204. package/dist/translations/th.js +5 -0
  205. package/dist/translations/th.umd.js +11 -0
  206. package/dist/translations/tk.d.ts +8 -0
  207. package/dist/translations/tk.js +5 -0
  208. package/dist/translations/tk.umd.js +11 -0
  209. package/dist/translations/tr.d.ts +8 -0
  210. package/dist/translations/tr.js +5 -0
  211. package/dist/translations/tr.umd.js +11 -0
  212. package/dist/translations/ug.d.ts +8 -0
  213. package/dist/translations/ug.js +5 -0
  214. package/dist/translations/ug.umd.js +11 -0
  215. package/dist/translations/uk.d.ts +8 -0
  216. package/dist/translations/uk.js +5 -0
  217. package/dist/translations/uk.umd.js +11 -0
  218. package/dist/translations/ur.d.ts +8 -0
  219. package/dist/translations/ur.js +5 -0
  220. package/dist/translations/ur.umd.js +11 -0
  221. package/dist/translations/uz.d.ts +8 -0
  222. package/dist/translations/uz.js +5 -0
  223. package/dist/translations/uz.umd.js +11 -0
  224. package/dist/translations/vi.d.ts +8 -0
  225. package/dist/translations/vi.js +5 -0
  226. package/dist/translations/vi.umd.js +11 -0
  227. package/dist/translations/zh-cn.d.ts +8 -0
  228. package/dist/translations/zh-cn.js +5 -0
  229. package/dist/translations/zh-cn.umd.js +11 -0
  230. package/dist/translations/zh.d.ts +8 -0
  231. package/dist/translations/zh.js +5 -0
  232. package/dist/translations/zh.umd.js +11 -0
  233. package/lang/contexts.json +4 -0
  234. package/lang/translations/ar.po +26 -0
  235. package/lang/translations/az.po +26 -0
  236. package/lang/translations/bg.po +26 -0
  237. package/lang/translations/bn.po +26 -0
  238. package/lang/translations/ca.po +26 -0
  239. package/lang/translations/cs.po +26 -0
  240. package/lang/translations/da.po +26 -0
  241. package/lang/translations/de-ch.po +26 -0
  242. package/lang/translations/de.po +26 -0
  243. package/lang/translations/el.po +26 -0
  244. package/lang/translations/en-au.po +26 -0
  245. package/lang/translations/en-gb.po +26 -0
  246. package/lang/translations/en.po +26 -0
  247. package/lang/translations/es.po +26 -0
  248. package/lang/translations/et.po +26 -0
  249. package/lang/translations/fa.po +26 -0
  250. package/lang/translations/fi.po +26 -0
  251. package/lang/translations/fr.po +26 -0
  252. package/lang/translations/gl.po +26 -0
  253. package/lang/translations/he.po +26 -0
  254. package/lang/translations/hi.po +26 -0
  255. package/lang/translations/hr.po +26 -0
  256. package/lang/translations/hu.po +26 -0
  257. package/lang/translations/id.po +26 -0
  258. package/lang/translations/it.po +26 -0
  259. package/lang/translations/ja.po +26 -0
  260. package/lang/translations/ko.po +26 -0
  261. package/lang/translations/ku.po +26 -0
  262. package/lang/translations/lt.po +26 -0
  263. package/lang/translations/lv.po +26 -0
  264. package/lang/translations/ms.po +26 -0
  265. package/lang/translations/ne.po +26 -0
  266. package/lang/translations/nl.po +26 -0
  267. package/lang/translations/no.po +26 -0
  268. package/lang/translations/pl.po +26 -0
  269. package/lang/translations/pt-br.po +26 -0
  270. package/lang/translations/pt.po +26 -0
  271. package/lang/translations/ro.po +26 -0
  272. package/lang/translations/ru.po +26 -0
  273. package/lang/translations/sk.po +26 -0
  274. package/lang/translations/sr-latn.po +26 -0
  275. package/lang/translations/sr.po +26 -0
  276. package/lang/translations/sv.po +26 -0
  277. package/lang/translations/th.po +26 -0
  278. package/lang/translations/tk.po +26 -0
  279. package/lang/translations/tr.po +26 -0
  280. package/lang/translations/ug.po +26 -0
  281. package/lang/translations/uk.po +26 -0
  282. package/lang/translations/ur.po +26 -0
  283. package/lang/translations/uz.po +26 -0
  284. package/lang/translations/vi.po +26 -0
  285. package/lang/translations/zh-cn.po +26 -0
  286. package/lang/translations/zh.po +26 -0
  287. package/package.json +42 -0
  288. package/src/augmentation.d.ts +24 -0
  289. package/src/augmentation.js +5 -0
  290. package/src/indent.d.ts +44 -0
  291. package/src/indent.js +50 -0
  292. package/src/indentblock.d.ts +46 -0
  293. package/src/indentblock.js +153 -0
  294. package/src/indentblockcommand.d.ts +56 -0
  295. package/src/indentblockcommand.js +98 -0
  296. package/src/indentcommandbehavior/indentbehavior.d.ts +25 -0
  297. package/src/indentcommandbehavior/indentbehavior.js +5 -0
  298. package/src/indentcommandbehavior/indentusingclasses.d.ts +39 -0
  299. package/src/indentcommandbehavior/indentusingclasses.js +39 -0
  300. package/src/indentcommandbehavior/indentusingoffset.d.ts +45 -0
  301. package/src/indentcommandbehavior/indentusingoffset.js +42 -0
  302. package/src/indentconfig.d.ts +72 -0
  303. package/src/indentconfig.js +5 -0
  304. package/src/indentediting.d.ts +30 -0
  305. package/src/indentediting.js +38 -0
  306. package/src/indentui.d.ts +35 -0
  307. package/src/indentui.js +78 -0
  308. package/src/index.d.ts +14 -0
  309. package/src/index.js +12 -0
@@ -0,0 +1,76 @@
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
+ * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
7
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
8
+ */
9
+ /**
10
+ * @module indent/indentconfig
11
+ */
12
+ /**
13
+ * The configuration of the block indentation feature.
14
+ *
15
+ * If no {@link module:indent/indentconfig~IndentBlockConfig#classes} are set, the block indentation feature will use
16
+ * {@link module:indent/indentconfig~IndentBlockConfig#offset} and {@link module:indent/indentconfig~IndentBlockConfig#unit} to
17
+ * create indentation steps.
18
+ *
19
+ * ```ts
20
+ * ClassicEditor
21
+ * .create( editorElement, {
22
+ * indentBlock: {
23
+ * offset: 2,
24
+ * unit: 'em'
25
+ * }
26
+ * } )
27
+ * .then( ... )
28
+ * .catch( ... );
29
+ * ```
30
+ *
31
+ * Alternatively, the block indentation feature may set one of defined {@link module:indent/indentconfig~IndentBlockConfig#classes} as
32
+ * indentation steps:
33
+ *
34
+ * ```ts
35
+ * ClassicEditor
36
+ * .create( editorElement, {
37
+ * indentBlock: {
38
+ * classes: [
39
+ * 'indent-a', // The first step - smallest indentation.
40
+ * 'indent-b',
41
+ * 'indent-c',
42
+ * 'indent-d',
43
+ * 'indent-e' // The last step - biggest indentation.
44
+ * ]
45
+ * }
46
+ * } )
47
+ * .then( ... )
48
+ * .catch( ... );
49
+ * ```
50
+ *
51
+ * In the example above only 5 indentation steps will be available.
52
+ *
53
+ * See {@link module:core/editor/editorconfig~EditorConfig all editor options}.
54
+ */
55
+ export interface IndentBlockConfig {
56
+ /**
57
+ * The size of indentation {@link module:indent/indentconfig~IndentBlockConfig#unit units} for each indentation step.
58
+ *
59
+ * @default 40
60
+ */
61
+ offset?: number;
62
+ /**
63
+ * The unit used for indentation {@link module:indent/indentconfig~IndentBlockConfig#offset}.
64
+ *
65
+ * @default 'px'
66
+ */
67
+ unit?: string;
68
+ /**
69
+ * An optional list of classes to use for indenting the editor content. If not set or set to an empty array, no classes will be used.
70
+ * The {@link module:indent/indentconfig~IndentBlockConfig#unit `indentBlock.unit`} and
71
+ * {@link module:indent/indentconfig~IndentBlockConfig#offset `indentBlock.offset`} properties will be used instead.
72
+ *
73
+ * @default undefined
74
+ */
75
+ classes?: Array<string>;
76
+ }
@@ -0,0 +1,34 @@
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
+ * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
7
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
8
+ */
9
+ /**
10
+ * @module indent/indentediting
11
+ */
12
+ import { Plugin } from 'ckeditor5/src/core.js';
13
+ /**
14
+ * The indent editing feature.
15
+ *
16
+ * This plugin registers the `'indent'` and `'outdent'` commands.
17
+ *
18
+ * **Note**: In order for the commands to work, at least one of the compatible features is required. Read more in the
19
+ * {@link module:indent/indent~Indent indent feature} API documentation.
20
+ */
21
+ export default class IndentEditing extends Plugin {
22
+ /**
23
+ * @inheritDoc
24
+ */
25
+ static get pluginName(): "IndentEditing";
26
+ /**
27
+ * @inheritDoc
28
+ */
29
+ static get isOfficialPlugin(): true;
30
+ /**
31
+ * @inheritDoc
32
+ */
33
+ init(): void;
34
+ }
@@ -0,0 +1,39 @@
1
+ /**
2
+ * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
3
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
+ */
5
+ /**
6
+ * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
7
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
8
+ */
9
+ import { Plugin } from 'ckeditor5/src/core.js';
10
+ /**
11
+ * The indent UI feature.
12
+ *
13
+ * This plugin registers the `'indent'` and `'outdent'` buttons.
14
+ *
15
+ * **Note**: In order for the commands to work, at least one of the compatible features is required. Read more in
16
+ * the {@link module:indent/indent~Indent indent feature} API documentation.
17
+ */
18
+ export default class IndentUI extends Plugin {
19
+ /**
20
+ * @inheritDoc
21
+ */
22
+ static get pluginName(): "IndentUI";
23
+ /**
24
+ * @inheritDoc
25
+ */
26
+ static get isOfficialPlugin(): true;
27
+ /**
28
+ * @inheritDoc
29
+ */
30
+ init(): void;
31
+ /**
32
+ * Defines UI buttons for both toolbar and menu bar.
33
+ */
34
+ private _defineButton;
35
+ /**
36
+ * Creates a button to use either in toolbar or in menu bar.
37
+ */
38
+ private _createButton;
39
+ }
@@ -0,0 +1,4 @@
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
+ */
@@ -0,0 +1,4 @@
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
+ */
package/dist/index.css ADDED
@@ -0,0 +1,4 @@
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
+ */
@@ -0,0 +1,18 @@
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
+ * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
7
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
8
+ */
9
+ /**
10
+ * @module indent
11
+ */
12
+ export { default as Indent } from './indent.js';
13
+ export { default as IndentEditing } from './indentediting.js';
14
+ export { default as IndentUI } from './indentui.js';
15
+ export { default as IndentBlock } from './indentblock.js';
16
+ export type { IndentBlockConfig } from './indentconfig.js';
17
+ export type { default as IndentBlockCommand } from './indentblockcommand.js';
18
+ import './augmentation.js';
package/dist/index.js ADDED
@@ -0,0 +1,466 @@
1
+ /**
2
+ * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
3
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
+ */
5
+ import { Plugin, MultiCommand, icons, Command } from '@ckeditor/ckeditor5-core/dist/index.js';
6
+ import { ButtonView, MenuBarMenuListItemButtonView } from '@ckeditor/ckeditor5-ui/dist/index.js';
7
+ import { addMarginRules } from '@ckeditor/ckeditor5-engine/dist/index.js';
8
+ import { first } from '@ckeditor/ckeditor5-utils/dist/index.js';
9
+
10
+ /**
11
+ * The indent editing feature.
12
+ *
13
+ * This plugin registers the `'indent'` and `'outdent'` commands.
14
+ *
15
+ * **Note**: In order for the commands to work, at least one of the compatible features is required. Read more in the
16
+ * {@link module:indent/indent~Indent indent feature} API documentation.
17
+ */ class IndentEditing extends Plugin {
18
+ /**
19
+ * @inheritDoc
20
+ */ static get pluginName() {
21
+ return 'IndentEditing';
22
+ }
23
+ /**
24
+ * @inheritDoc
25
+ */ static get isOfficialPlugin() {
26
+ return true;
27
+ }
28
+ /**
29
+ * @inheritDoc
30
+ */ init() {
31
+ const editor = this.editor;
32
+ editor.commands.add('indent', new MultiCommand(editor));
33
+ editor.commands.add('outdent', new MultiCommand(editor));
34
+ }
35
+ }
36
+
37
+ /**
38
+ * The indent UI feature.
39
+ *
40
+ * This plugin registers the `'indent'` and `'outdent'` buttons.
41
+ *
42
+ * **Note**: In order for the commands to work, at least one of the compatible features is required. Read more in
43
+ * the {@link module:indent/indent~Indent indent feature} API documentation.
44
+ */ class IndentUI extends Plugin {
45
+ /**
46
+ * @inheritDoc
47
+ */ static get pluginName() {
48
+ return 'IndentUI';
49
+ }
50
+ /**
51
+ * @inheritDoc
52
+ */ static get isOfficialPlugin() {
53
+ return true;
54
+ }
55
+ /**
56
+ * @inheritDoc
57
+ */ init() {
58
+ const editor = this.editor;
59
+ const locale = editor.locale;
60
+ const t = editor.t;
61
+ const localizedIndentIcon = locale.uiLanguageDirection == 'ltr' ? icons.indent : icons.outdent;
62
+ const localizedOutdentIcon = locale.uiLanguageDirection == 'ltr' ? icons.outdent : icons.indent;
63
+ this._defineButton('indent', t('Increase indent'), localizedIndentIcon);
64
+ this._defineButton('outdent', t('Decrease indent'), localizedOutdentIcon);
65
+ }
66
+ /**
67
+ * Defines UI buttons for both toolbar and menu bar.
68
+ */ _defineButton(commandName, label, icon) {
69
+ const editor = this.editor;
70
+ editor.ui.componentFactory.add(commandName, ()=>{
71
+ const buttonView = this._createButton(ButtonView, commandName, label, icon);
72
+ buttonView.set({
73
+ tooltip: true
74
+ });
75
+ return buttonView;
76
+ });
77
+ editor.ui.componentFactory.add('menuBar:' + commandName, ()=>{
78
+ return this._createButton(MenuBarMenuListItemButtonView, commandName, label, icon);
79
+ });
80
+ }
81
+ /**
82
+ * Creates a button to use either in toolbar or in menu bar.
83
+ */ _createButton(ButtonClass, commandName, label, icon) {
84
+ const editor = this.editor;
85
+ const command = editor.commands.get(commandName);
86
+ const view = new ButtonClass(editor.locale);
87
+ view.set({
88
+ label,
89
+ icon
90
+ });
91
+ view.bind('isEnabled').to(command, 'isEnabled');
92
+ // Execute the command.
93
+ this.listenTo(view, 'execute', ()=>{
94
+ editor.execute(commandName);
95
+ editor.editing.view.focus();
96
+ });
97
+ return view;
98
+ }
99
+ }
100
+
101
+ /**
102
+ * The indent feature.
103
+ *
104
+ * This plugin acts as a single entry point plugin for other features that implement indentation of elements like lists or paragraphs.
105
+ *
106
+ * The compatible features are:
107
+ *
108
+ * * The {@link module:list/list~List} or {@link module:list/list/listediting~ListEditing} feature for list indentation.
109
+ * * The {@link module:indent/indentblock~IndentBlock} feature for block indentation.
110
+ *
111
+ * This is a "glue" plugin that loads the following plugins:
112
+ *
113
+ * * The {@link module:indent/indentediting~IndentEditing indent editing feature}.
114
+ * * The {@link module:indent/indentui~IndentUI indent UI feature}.
115
+ *
116
+ * The dependent plugins register the `'indent'` and `'outdent'` commands and introduce the `'indent'` and `'outdent'` buttons
117
+ * that allow to increase or decrease text indentation of supported elements.
118
+ *
119
+ * **Note**: In order for the commands and buttons to work, at least one of compatible features is required.
120
+ */ class Indent extends Plugin {
121
+ /**
122
+ * @inheritDoc
123
+ */ static get pluginName() {
124
+ return 'Indent';
125
+ }
126
+ /**
127
+ * @inheritDoc
128
+ */ static get isOfficialPlugin() {
129
+ return true;
130
+ }
131
+ /**
132
+ * @inheritDoc
133
+ */ static get requires() {
134
+ return [
135
+ IndentEditing,
136
+ IndentUI
137
+ ];
138
+ }
139
+ }
140
+
141
+ /**
142
+ * The indent block command.
143
+ *
144
+ * The command is registered by the {@link module:indent/indentblock~IndentBlock} as `'indentBlock'` for indenting blocks and
145
+ * `'outdentBlock'` for outdenting blocks.
146
+ *
147
+ * To increase block indentation at the current selection, execute the command:
148
+ *
149
+ * ```ts
150
+ * editor.execute( 'indentBlock' );
151
+ * ```
152
+ *
153
+ * To decrease block indentation at the current selection, execute the command:
154
+ *
155
+ * ```ts
156
+ * editor.execute( 'outdentBlock' );
157
+ * ```
158
+ */ class IndentBlockCommand extends Command {
159
+ /**
160
+ * The command's indentation behavior.
161
+ */ _indentBehavior;
162
+ /**
163
+ * Creates an instance of the command.
164
+ */ constructor(editor, indentBehavior){
165
+ super(editor);
166
+ this._indentBehavior = indentBehavior;
167
+ }
168
+ /**
169
+ * @inheritDoc
170
+ */ refresh() {
171
+ const editor = this.editor;
172
+ const model = editor.model;
173
+ const block = first(model.document.selection.getSelectedBlocks());
174
+ if (!block || !this._isIndentationChangeAllowed(block)) {
175
+ this.isEnabled = false;
176
+ return;
177
+ }
178
+ this.isEnabled = this._indentBehavior.checkEnabled(block.getAttribute('blockIndent'));
179
+ }
180
+ /**
181
+ * @inheritDoc
182
+ */ execute() {
183
+ const model = this.editor.model;
184
+ const blocksToChange = this._getBlocksToChange();
185
+ model.change((writer)=>{
186
+ for (const block of blocksToChange){
187
+ const currentIndent = block.getAttribute('blockIndent');
188
+ const nextIndent = this._indentBehavior.getNextIndent(currentIndent);
189
+ if (nextIndent) {
190
+ writer.setAttribute('blockIndent', nextIndent, block);
191
+ } else {
192
+ writer.removeAttribute('blockIndent', block);
193
+ }
194
+ }
195
+ });
196
+ }
197
+ /**
198
+ * Returns blocks from selection that should have blockIndent selection set.
199
+ */ _getBlocksToChange() {
200
+ const model = this.editor.model;
201
+ const selection = model.document.selection;
202
+ const blocksInSelection = Array.from(selection.getSelectedBlocks());
203
+ return blocksInSelection.filter((block)=>this._isIndentationChangeAllowed(block));
204
+ }
205
+ /**
206
+ * Returns false if indentation cannot be applied, i.e.:
207
+ * - for blocks disallowed by schema declaration
208
+ * - for blocks in Document Lists (disallowed forward indentation only). See https://github.com/ckeditor/ckeditor5/issues/14155.
209
+ * Otherwise returns true.
210
+ */ _isIndentationChangeAllowed(element) {
211
+ const editor = this.editor;
212
+ if (!editor.model.schema.checkAttribute(element, 'blockIndent')) {
213
+ return false;
214
+ }
215
+ if (!editor.plugins.has('ListUtils')) {
216
+ return true;
217
+ }
218
+ // Only forward indentation is disallowed in list items. This allows the user to outdent blocks that are already indented.
219
+ if (!this._indentBehavior.isForward) {
220
+ return true;
221
+ }
222
+ const documentListUtils = editor.plugins.get('ListUtils');
223
+ return !documentListUtils.isListItemBlock(element);
224
+ }
225
+ }
226
+
227
+ /**
228
+ * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
229
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
230
+ */ /**
231
+ * @module indent/indentcommandbehavior/indentusingoffset
232
+ */ /**
233
+ * The block indentation behavior that uses offsets to set indentation.
234
+ */ class IndentUsingOffset {
235
+ /**
236
+ * The direction of indentation.
237
+ */ isForward;
238
+ /**
239
+ * The offset of the next indentation step.
240
+ */ offset;
241
+ /**
242
+ * Indentation unit.
243
+ */ unit;
244
+ /**
245
+ * Creates an instance of the indentation behavior.
246
+ *
247
+ * @param config.direction The direction of indentation.
248
+ * @param config.offset The offset of the next indentation step.
249
+ * @param config.unit Indentation unit.
250
+ */ constructor(config){
251
+ this.isForward = config.direction === 'forward';
252
+ this.offset = config.offset;
253
+ this.unit = config.unit;
254
+ }
255
+ /**
256
+ * @inheritDoc
257
+ */ checkEnabled(indentAttributeValue) {
258
+ const currentOffset = parseFloat(indentAttributeValue || '0');
259
+ // The command is always enabled for forward indentation.
260
+ return this.isForward || currentOffset > 0;
261
+ }
262
+ /**
263
+ * @inheritDoc
264
+ */ getNextIndent(indentAttributeValue) {
265
+ const currentOffset = parseFloat(indentAttributeValue || '0');
266
+ const isSameUnit = !indentAttributeValue || indentAttributeValue.endsWith(this.unit);
267
+ if (!isSameUnit) {
268
+ return this.isForward ? this.offset + this.unit : undefined;
269
+ }
270
+ const nextOffset = this.isForward ? this.offset : -this.offset;
271
+ const offsetToSet = currentOffset + nextOffset;
272
+ return offsetToSet > 0 ? offsetToSet + this.unit : undefined;
273
+ }
274
+ }
275
+
276
+ /**
277
+ * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
278
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
279
+ */ /**
280
+ * @module indent/indentcommandbehavior/indentusingclasses
281
+ */ /**
282
+ * The block indentation behavior that uses classes to set indentation.
283
+ */ class IndentUsingClasses {
284
+ /**
285
+ * The direction of indentation.
286
+ */ isForward;
287
+ /**
288
+ * A list of classes used for indentation.
289
+ */ classes;
290
+ /**
291
+ * Creates an instance of the indentation behavior.
292
+ *
293
+ * @param config.direction The direction of indentation.
294
+ * @param config.classes A list of classes used for indentation.
295
+ */ constructor(config){
296
+ this.isForward = config.direction === 'forward';
297
+ this.classes = config.classes;
298
+ }
299
+ /**
300
+ * @inheritDoc
301
+ */ checkEnabled(indentAttributeValue) {
302
+ const currentIndex = this.classes.indexOf(indentAttributeValue);
303
+ if (this.isForward) {
304
+ return currentIndex < this.classes.length - 1;
305
+ } else {
306
+ return currentIndex >= 0;
307
+ }
308
+ }
309
+ /**
310
+ * @inheritDoc
311
+ */ getNextIndent(indentAttributeValue) {
312
+ const currentIndex = this.classes.indexOf(indentAttributeValue);
313
+ const indexStep = this.isForward ? 1 : -1;
314
+ return this.classes[currentIndex + indexStep];
315
+ }
316
+ }
317
+
318
+ const DEFAULT_ELEMENTS = [
319
+ 'paragraph',
320
+ 'heading1',
321
+ 'heading2',
322
+ 'heading3',
323
+ 'heading4',
324
+ 'heading5',
325
+ 'heading6'
326
+ ];
327
+ /**
328
+ * The block indentation feature.
329
+ *
330
+ * It registers the `'indentBlock'` and `'outdentBlock'` commands.
331
+ *
332
+ * If the plugin {@link module:indent/indent~Indent} is defined, it also attaches the `'indentBlock'` and `'outdentBlock'` commands to
333
+ * the `'indent'` and `'outdent'` commands.
334
+ */ class IndentBlock extends Plugin {
335
+ /**
336
+ * @inheritDoc
337
+ */ constructor(editor){
338
+ super(editor);
339
+ editor.config.define('indentBlock', {
340
+ offset: 40,
341
+ unit: 'px'
342
+ });
343
+ }
344
+ /**
345
+ * @inheritDoc
346
+ */ static get pluginName() {
347
+ return 'IndentBlock';
348
+ }
349
+ /**
350
+ * @inheritDoc
351
+ */ static get isOfficialPlugin() {
352
+ return true;
353
+ }
354
+ /**
355
+ * @inheritDoc
356
+ */ init() {
357
+ const editor = this.editor;
358
+ const configuration = editor.config.get('indentBlock');
359
+ if (configuration.classes && configuration.classes.length) {
360
+ this._setupConversionUsingClasses(configuration.classes);
361
+ editor.commands.add('indentBlock', new IndentBlockCommand(editor, new IndentUsingClasses({
362
+ direction: 'forward',
363
+ classes: configuration.classes
364
+ })));
365
+ editor.commands.add('outdentBlock', new IndentBlockCommand(editor, new IndentUsingClasses({
366
+ direction: 'backward',
367
+ classes: configuration.classes
368
+ })));
369
+ } else {
370
+ editor.data.addStyleProcessorRules(addMarginRules);
371
+ this._setupConversionUsingOffset();
372
+ editor.commands.add('indentBlock', new IndentBlockCommand(editor, new IndentUsingOffset({
373
+ direction: 'forward',
374
+ offset: configuration.offset,
375
+ unit: configuration.unit
376
+ })));
377
+ editor.commands.add('outdentBlock', new IndentBlockCommand(editor, new IndentUsingOffset({
378
+ direction: 'backward',
379
+ offset: configuration.offset,
380
+ unit: configuration.unit
381
+ })));
382
+ }
383
+ }
384
+ /**
385
+ * @inheritDoc
386
+ */ afterInit() {
387
+ const editor = this.editor;
388
+ const schema = editor.model.schema;
389
+ const indentCommand = editor.commands.get('indent');
390
+ const outdentCommand = editor.commands.get('outdent');
391
+ // Enable block indentation to heading configuration options. If it is not defined enable in paragraph and default headings.
392
+ const options = editor.config.get('heading.options');
393
+ const configuredElements = options && options.map((option)=>option.model);
394
+ const knownElements = configuredElements || DEFAULT_ELEMENTS;
395
+ knownElements.forEach((elementName)=>{
396
+ if (schema.isRegistered(elementName)) {
397
+ schema.extend(elementName, {
398
+ allowAttributes: 'blockIndent'
399
+ });
400
+ }
401
+ });
402
+ schema.setAttributeProperties('blockIndent', {
403
+ isFormatting: true
404
+ });
405
+ indentCommand.registerChildCommand(editor.commands.get('indentBlock'));
406
+ outdentCommand.registerChildCommand(editor.commands.get('outdentBlock'));
407
+ }
408
+ /**
409
+ * Setups conversion for using offset indents.
410
+ */ _setupConversionUsingOffset() {
411
+ const conversion = this.editor.conversion;
412
+ const locale = this.editor.locale;
413
+ const marginProperty = locale.contentLanguageDirection === 'rtl' ? 'margin-right' : 'margin-left';
414
+ conversion.for('upcast').attributeToAttribute({
415
+ view: {
416
+ styles: {
417
+ [marginProperty]: /[\s\S]+/
418
+ }
419
+ },
420
+ model: {
421
+ key: 'blockIndent',
422
+ value: (viewElement)=>{
423
+ // Do not indent block elements in Document Lists. See https://github.com/ckeditor/ckeditor5/issues/12466.
424
+ if (!viewElement.is('element', 'li')) {
425
+ return viewElement.getStyle(marginProperty);
426
+ }
427
+ }
428
+ }
429
+ });
430
+ conversion.for('downcast').attributeToAttribute({
431
+ model: 'blockIndent',
432
+ view: (modelAttributeValue)=>{
433
+ return {
434
+ key: 'style',
435
+ value: {
436
+ [marginProperty]: modelAttributeValue
437
+ }
438
+ };
439
+ }
440
+ });
441
+ }
442
+ /**
443
+ * Setups conversion for using classes.
444
+ */ _setupConversionUsingClasses(classes) {
445
+ const definition = {
446
+ model: {
447
+ key: 'blockIndent',
448
+ values: []
449
+ },
450
+ view: {}
451
+ };
452
+ for (const className of classes){
453
+ definition.model.values.push(className);
454
+ definition.view[className] = {
455
+ key: 'class',
456
+ value: [
457
+ className
458
+ ]
459
+ };
460
+ }
461
+ this.editor.conversion.attributeToAttribute(definition);
462
+ }
463
+ }
464
+
465
+ export { Indent, IndentBlock, IndentEditing, IndentUI };
466
+ //# sourceMappingURL=index.js.map