@ckeditor/ckeditor5-language 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 (280) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/LICENSE.md +17 -0
  3. package/README.md +26 -0
  4. package/build/language.js +5 -0
  5. package/build/translations/ar.js +1 -0
  6. package/build/translations/bg.js +1 -0
  7. package/build/translations/bn.js +1 -0
  8. package/build/translations/ca.js +1 -0
  9. package/build/translations/cs.js +1 -0
  10. package/build/translations/da.js +1 -0
  11. package/build/translations/de-ch.js +1 -0
  12. package/build/translations/de.js +1 -0
  13. package/build/translations/el.js +1 -0
  14. package/build/translations/en-au.js +1 -0
  15. package/build/translations/es.js +1 -0
  16. package/build/translations/et.js +1 -0
  17. package/build/translations/fi.js +1 -0
  18. package/build/translations/fr.js +1 -0
  19. package/build/translations/gl.js +1 -0
  20. package/build/translations/he.js +1 -0
  21. package/build/translations/hi.js +1 -0
  22. package/build/translations/hr.js +1 -0
  23. package/build/translations/hu.js +1 -0
  24. package/build/translations/id.js +1 -0
  25. package/build/translations/it.js +1 -0
  26. package/build/translations/ja.js +1 -0
  27. package/build/translations/jv.js +1 -0
  28. package/build/translations/ko.js +1 -0
  29. package/build/translations/lt.js +1 -0
  30. package/build/translations/lv.js +1 -0
  31. package/build/translations/ms.js +1 -0
  32. package/build/translations/nl.js +1 -0
  33. package/build/translations/no.js +1 -0
  34. package/build/translations/pl.js +1 -0
  35. package/build/translations/pt-br.js +1 -0
  36. package/build/translations/pt.js +1 -0
  37. package/build/translations/ro.js +1 -0
  38. package/build/translations/ru.js +1 -0
  39. package/build/translations/sk.js +1 -0
  40. package/build/translations/sr-latn.js +1 -0
  41. package/build/translations/sr.js +1 -0
  42. package/build/translations/sv.js +1 -0
  43. package/build/translations/th.js +1 -0
  44. package/build/translations/tk.js +1 -0
  45. package/build/translations/tr.js +1 -0
  46. package/build/translations/tt.js +1 -0
  47. package/build/translations/ug.js +1 -0
  48. package/build/translations/uk.js +1 -0
  49. package/build/translations/ur.js +1 -0
  50. package/build/translations/vi.js +1 -0
  51. package/build/translations/zh-cn.js +1 -0
  52. package/build/translations/zh.js +1 -0
  53. package/ckeditor5-metadata.json +27 -0
  54. package/dist/augmentation.d.ts +51 -0
  55. package/dist/index-content.css +4 -0
  56. package/dist/index-editor.css +4 -0
  57. package/dist/index.css +4 -0
  58. package/dist/index.d.ts +17 -0
  59. package/dist/index.js +402 -0
  60. package/dist/index.js.map +1 -0
  61. package/dist/textpartlanguage.d.ts +43 -0
  62. package/dist/textpartlanguagecommand.d.ts +74 -0
  63. package/dist/textpartlanguageconfig.d.ts +29 -0
  64. package/dist/textpartlanguageediting.d.ts +36 -0
  65. package/dist/textpartlanguageui.d.ts +35 -0
  66. package/dist/translations/ar.d.ts +8 -0
  67. package/dist/translations/ar.js +5 -0
  68. package/dist/translations/ar.umd.js +11 -0
  69. package/dist/translations/bg.d.ts +8 -0
  70. package/dist/translations/bg.js +5 -0
  71. package/dist/translations/bg.umd.js +11 -0
  72. package/dist/translations/bn.d.ts +8 -0
  73. package/dist/translations/bn.js +5 -0
  74. package/dist/translations/bn.umd.js +11 -0
  75. package/dist/translations/ca.d.ts +8 -0
  76. package/dist/translations/ca.js +5 -0
  77. package/dist/translations/ca.umd.js +11 -0
  78. package/dist/translations/cs.d.ts +8 -0
  79. package/dist/translations/cs.js +5 -0
  80. package/dist/translations/cs.umd.js +11 -0
  81. package/dist/translations/da.d.ts +8 -0
  82. package/dist/translations/da.js +5 -0
  83. package/dist/translations/da.umd.js +11 -0
  84. package/dist/translations/de-ch.d.ts +8 -0
  85. package/dist/translations/de-ch.js +5 -0
  86. package/dist/translations/de-ch.umd.js +11 -0
  87. package/dist/translations/de.d.ts +8 -0
  88. package/dist/translations/de.js +5 -0
  89. package/dist/translations/de.umd.js +11 -0
  90. package/dist/translations/el.d.ts +8 -0
  91. package/dist/translations/el.js +5 -0
  92. package/dist/translations/el.umd.js +11 -0
  93. package/dist/translations/en-au.d.ts +8 -0
  94. package/dist/translations/en-au.js +5 -0
  95. package/dist/translations/en-au.umd.js +11 -0
  96. package/dist/translations/en.d.ts +8 -0
  97. package/dist/translations/en.js +5 -0
  98. package/dist/translations/en.umd.js +11 -0
  99. package/dist/translations/es.d.ts +8 -0
  100. package/dist/translations/es.js +5 -0
  101. package/dist/translations/es.umd.js +11 -0
  102. package/dist/translations/et.d.ts +8 -0
  103. package/dist/translations/et.js +5 -0
  104. package/dist/translations/et.umd.js +11 -0
  105. package/dist/translations/fi.d.ts +8 -0
  106. package/dist/translations/fi.js +5 -0
  107. package/dist/translations/fi.umd.js +11 -0
  108. package/dist/translations/fr.d.ts +8 -0
  109. package/dist/translations/fr.js +5 -0
  110. package/dist/translations/fr.umd.js +11 -0
  111. package/dist/translations/gl.d.ts +8 -0
  112. package/dist/translations/gl.js +5 -0
  113. package/dist/translations/gl.umd.js +11 -0
  114. package/dist/translations/he.d.ts +8 -0
  115. package/dist/translations/he.js +5 -0
  116. package/dist/translations/he.umd.js +11 -0
  117. package/dist/translations/hi.d.ts +8 -0
  118. package/dist/translations/hi.js +5 -0
  119. package/dist/translations/hi.umd.js +11 -0
  120. package/dist/translations/hr.d.ts +8 -0
  121. package/dist/translations/hr.js +5 -0
  122. package/dist/translations/hr.umd.js +11 -0
  123. package/dist/translations/hu.d.ts +8 -0
  124. package/dist/translations/hu.js +5 -0
  125. package/dist/translations/hu.umd.js +11 -0
  126. package/dist/translations/id.d.ts +8 -0
  127. package/dist/translations/id.js +5 -0
  128. package/dist/translations/id.umd.js +11 -0
  129. package/dist/translations/it.d.ts +8 -0
  130. package/dist/translations/it.js +5 -0
  131. package/dist/translations/it.umd.js +11 -0
  132. package/dist/translations/ja.d.ts +8 -0
  133. package/dist/translations/ja.js +5 -0
  134. package/dist/translations/ja.umd.js +11 -0
  135. package/dist/translations/jv.d.ts +8 -0
  136. package/dist/translations/jv.js +5 -0
  137. package/dist/translations/jv.umd.js +11 -0
  138. package/dist/translations/ko.d.ts +8 -0
  139. package/dist/translations/ko.js +5 -0
  140. package/dist/translations/ko.umd.js +11 -0
  141. package/dist/translations/lt.d.ts +8 -0
  142. package/dist/translations/lt.js +5 -0
  143. package/dist/translations/lt.umd.js +11 -0
  144. package/dist/translations/lv.d.ts +8 -0
  145. package/dist/translations/lv.js +5 -0
  146. package/dist/translations/lv.umd.js +11 -0
  147. package/dist/translations/ms.d.ts +8 -0
  148. package/dist/translations/ms.js +5 -0
  149. package/dist/translations/ms.umd.js +11 -0
  150. package/dist/translations/nl.d.ts +8 -0
  151. package/dist/translations/nl.js +5 -0
  152. package/dist/translations/nl.umd.js +11 -0
  153. package/dist/translations/no.d.ts +8 -0
  154. package/dist/translations/no.js +5 -0
  155. package/dist/translations/no.umd.js +11 -0
  156. package/dist/translations/pl.d.ts +8 -0
  157. package/dist/translations/pl.js +5 -0
  158. package/dist/translations/pl.umd.js +11 -0
  159. package/dist/translations/pt-br.d.ts +8 -0
  160. package/dist/translations/pt-br.js +5 -0
  161. package/dist/translations/pt-br.umd.js +11 -0
  162. package/dist/translations/pt.d.ts +8 -0
  163. package/dist/translations/pt.js +5 -0
  164. package/dist/translations/pt.umd.js +11 -0
  165. package/dist/translations/ro.d.ts +8 -0
  166. package/dist/translations/ro.js +5 -0
  167. package/dist/translations/ro.umd.js +11 -0
  168. package/dist/translations/ru.d.ts +8 -0
  169. package/dist/translations/ru.js +5 -0
  170. package/dist/translations/ru.umd.js +11 -0
  171. package/dist/translations/sk.d.ts +8 -0
  172. package/dist/translations/sk.js +5 -0
  173. package/dist/translations/sk.umd.js +11 -0
  174. package/dist/translations/sr-latn.d.ts +8 -0
  175. package/dist/translations/sr-latn.js +5 -0
  176. package/dist/translations/sr-latn.umd.js +11 -0
  177. package/dist/translations/sr.d.ts +8 -0
  178. package/dist/translations/sr.js +5 -0
  179. package/dist/translations/sr.umd.js +11 -0
  180. package/dist/translations/sv.d.ts +8 -0
  181. package/dist/translations/sv.js +5 -0
  182. package/dist/translations/sv.umd.js +11 -0
  183. package/dist/translations/th.d.ts +8 -0
  184. package/dist/translations/th.js +5 -0
  185. package/dist/translations/th.umd.js +11 -0
  186. package/dist/translations/tk.d.ts +8 -0
  187. package/dist/translations/tk.js +5 -0
  188. package/dist/translations/tk.umd.js +11 -0
  189. package/dist/translations/tr.d.ts +8 -0
  190. package/dist/translations/tr.js +5 -0
  191. package/dist/translations/tr.umd.js +11 -0
  192. package/dist/translations/tt.d.ts +8 -0
  193. package/dist/translations/tt.js +5 -0
  194. package/dist/translations/tt.umd.js +11 -0
  195. package/dist/translations/ug.d.ts +8 -0
  196. package/dist/translations/ug.js +5 -0
  197. package/dist/translations/ug.umd.js +11 -0
  198. package/dist/translations/uk.d.ts +8 -0
  199. package/dist/translations/uk.js +5 -0
  200. package/dist/translations/uk.umd.js +11 -0
  201. package/dist/translations/ur.d.ts +8 -0
  202. package/dist/translations/ur.js +5 -0
  203. package/dist/translations/ur.umd.js +11 -0
  204. package/dist/translations/vi.d.ts +8 -0
  205. package/dist/translations/vi.js +5 -0
  206. package/dist/translations/vi.umd.js +11 -0
  207. package/dist/translations/zh-cn.d.ts +8 -0
  208. package/dist/translations/zh-cn.js +5 -0
  209. package/dist/translations/zh-cn.umd.js +11 -0
  210. package/dist/translations/zh.d.ts +8 -0
  211. package/dist/translations/zh.js +5 -0
  212. package/dist/translations/zh.umd.js +11 -0
  213. package/dist/utils.d.ts +44 -0
  214. package/lang/contexts.json +5 -0
  215. package/lang/translations/ar.po +30 -0
  216. package/lang/translations/bg.po +30 -0
  217. package/lang/translations/bn.po +30 -0
  218. package/lang/translations/ca.po +30 -0
  219. package/lang/translations/cs.po +30 -0
  220. package/lang/translations/da.po +30 -0
  221. package/lang/translations/de-ch.po +30 -0
  222. package/lang/translations/de.po +30 -0
  223. package/lang/translations/el.po +30 -0
  224. package/lang/translations/en-au.po +30 -0
  225. package/lang/translations/en.po +30 -0
  226. package/lang/translations/es.po +30 -0
  227. package/lang/translations/et.po +30 -0
  228. package/lang/translations/fi.po +30 -0
  229. package/lang/translations/fr.po +30 -0
  230. package/lang/translations/gl.po +30 -0
  231. package/lang/translations/he.po +30 -0
  232. package/lang/translations/hi.po +30 -0
  233. package/lang/translations/hr.po +30 -0
  234. package/lang/translations/hu.po +30 -0
  235. package/lang/translations/id.po +30 -0
  236. package/lang/translations/it.po +30 -0
  237. package/lang/translations/ja.po +30 -0
  238. package/lang/translations/jv.po +30 -0
  239. package/lang/translations/ko.po +30 -0
  240. package/lang/translations/lt.po +30 -0
  241. package/lang/translations/lv.po +30 -0
  242. package/lang/translations/ms.po +30 -0
  243. package/lang/translations/nl.po +30 -0
  244. package/lang/translations/no.po +30 -0
  245. package/lang/translations/pl.po +30 -0
  246. package/lang/translations/pt-br.po +30 -0
  247. package/lang/translations/pt.po +30 -0
  248. package/lang/translations/ro.po +30 -0
  249. package/lang/translations/ru.po +30 -0
  250. package/lang/translations/sk.po +30 -0
  251. package/lang/translations/sr-latn.po +30 -0
  252. package/lang/translations/sr.po +30 -0
  253. package/lang/translations/sv.po +30 -0
  254. package/lang/translations/th.po +30 -0
  255. package/lang/translations/tk.po +30 -0
  256. package/lang/translations/tr.po +30 -0
  257. package/lang/translations/tt.po +30 -0
  258. package/lang/translations/ug.po +30 -0
  259. package/lang/translations/uk.po +30 -0
  260. package/lang/translations/ur.po +30 -0
  261. package/lang/translations/vi.po +30 -0
  262. package/lang/translations/zh-cn.po +30 -0
  263. package/lang/translations/zh.po +30 -0
  264. package/package.json +41 -0
  265. package/src/augmentation.d.ts +47 -0
  266. package/src/augmentation.js +5 -0
  267. package/src/index.d.ts +13 -0
  268. package/src/index.js +11 -0
  269. package/src/textpartlanguage.d.ts +39 -0
  270. package/src/textpartlanguage.js +45 -0
  271. package/src/textpartlanguagecommand.d.ts +70 -0
  272. package/src/textpartlanguagecommand.js +89 -0
  273. package/src/textpartlanguageconfig.d.ts +25 -0
  274. package/src/textpartlanguageconfig.js +5 -0
  275. package/src/textpartlanguageediting.d.ts +32 -0
  276. package/src/textpartlanguageediting.js +90 -0
  277. package/src/textpartlanguageui.d.ts +31 -0
  278. package/src/textpartlanguageui.js +167 -0
  279. package/src/utils.d.ts +40 -0
  280. package/src/utils.js +43 -0
@@ -0,0 +1,30 @@
1
+ # Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
2
+ #
3
+ # !!! IMPORTANT !!!
4
+ #
5
+ # Before you edit this file, please keep in mind that contributing to the project
6
+ # translations is possible ONLY via the Transifex online service.
7
+ #
8
+ # To submit your translations, visit https://www.transifex.com/ckeditor/ckeditor5.
9
+ #
10
+ # To learn more, check out the official contributor's guide:
11
+ # https://ckeditor.com/docs/ckeditor5/latest/framework/guides/contributing/contributing.html
12
+ #
13
+ msgid ""
14
+ msgstr ""
15
+ "Language-Team: Vietnamese (https://app.transifex.com/ckeditor/teams/11143/vi/)\n"
16
+ "Language: vi\n"
17
+ "Plural-Forms: nplurals=1; plural=0;\n"
18
+ "Content-Type: text/plain; charset=UTF-8\n"
19
+
20
+ msgctxt "Toolbar button tooltip for the text part language feature."
21
+ msgid "Language"
22
+ msgstr "Ngôn ngữ"
23
+
24
+ msgctxt "Default label for the text part language dropdown."
25
+ msgid "Choose language"
26
+ msgstr "Chọn ngôn ngữ"
27
+
28
+ msgctxt "The label of the remove language option for the text part language dropdown."
29
+ msgid "Remove language"
30
+ msgstr "Xóa ngôn ngữ"
@@ -0,0 +1,30 @@
1
+ # Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
2
+ #
3
+ # !!! IMPORTANT !!!
4
+ #
5
+ # Before you edit this file, please keep in mind that contributing to the project
6
+ # translations is possible ONLY via the Transifex online service.
7
+ #
8
+ # To submit your translations, visit https://www.transifex.com/ckeditor/ckeditor5.
9
+ #
10
+ # To learn more, check out the official contributor's guide:
11
+ # https://ckeditor.com/docs/ckeditor5/latest/framework/guides/contributing/contributing.html
12
+ #
13
+ msgid ""
14
+ msgstr ""
15
+ "Language-Team: Chinese (China) (https://app.transifex.com/ckeditor/teams/11143/zh_CN/)\n"
16
+ "Language: zh_CN\n"
17
+ "Plural-Forms: nplurals=1; plural=0;\n"
18
+ "Content-Type: text/plain; charset=UTF-8\n"
19
+
20
+ msgctxt "Toolbar button tooltip for the text part language feature."
21
+ msgid "Language"
22
+ msgstr "语言"
23
+
24
+ msgctxt "Default label for the text part language dropdown."
25
+ msgid "Choose language"
26
+ msgstr "选择语言"
27
+
28
+ msgctxt "The label of the remove language option for the text part language dropdown."
29
+ msgid "Remove language"
30
+ msgstr "移除语言"
@@ -0,0 +1,30 @@
1
+ # Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
2
+ #
3
+ # !!! IMPORTANT !!!
4
+ #
5
+ # Before you edit this file, please keep in mind that contributing to the project
6
+ # translations is possible ONLY via the Transifex online service.
7
+ #
8
+ # To submit your translations, visit https://www.transifex.com/ckeditor/ckeditor5.
9
+ #
10
+ # To learn more, check out the official contributor's guide:
11
+ # https://ckeditor.com/docs/ckeditor5/latest/framework/guides/contributing/contributing.html
12
+ #
13
+ msgid ""
14
+ msgstr ""
15
+ "Language-Team: Chinese (Taiwan) (https://app.transifex.com/ckeditor/teams/11143/zh_TW/)\n"
16
+ "Language: zh_TW\n"
17
+ "Plural-Forms: nplurals=1; plural=0;\n"
18
+ "Content-Type: text/plain; charset=UTF-8\n"
19
+
20
+ msgctxt "Toolbar button tooltip for the text part language feature."
21
+ msgid "Language"
22
+ msgstr "語言"
23
+
24
+ msgctxt "Default label for the text part language dropdown."
25
+ msgid "Choose language"
26
+ msgstr "選擇語言"
27
+
28
+ msgctxt "The label of the remove language option for the text part language dropdown."
29
+ msgid "Remove language"
30
+ msgstr "移除語言"
package/package.json ADDED
@@ -0,0 +1,41 @@
1
+ {
2
+ "name": "@ckeditor/ckeditor5-language",
3
+ "version": "0.0.0-internal-20241017.0",
4
+ "description": "Text part language feature for CKEditor 5.",
5
+ "keywords": [
6
+ "ckeditor",
7
+ "ckeditor5",
8
+ "ckeditor 5",
9
+ "ckeditor5-feature",
10
+ "ckeditor5-plugin",
11
+ "ckeditor5-dll"
12
+ ],
13
+ "type": "module",
14
+ "main": "src/index.js",
15
+ "dependencies": {
16
+ "@ckeditor/ckeditor5-core": "0.0.0-internal-20241017.0",
17
+ "@ckeditor/ckeditor5-ui": "0.0.0-internal-20241017.0",
18
+ "@ckeditor/ckeditor5-utils": "0.0.0-internal-20241017.0",
19
+ "ckeditor5": "0.0.0-internal-20241017.0"
20
+ },
21
+ "author": "CKSource (http://cksource.com/)",
22
+ "license": "GPL-2.0-or-later",
23
+ "homepage": "https://ckeditor.com/ckeditor-5",
24
+ "bugs": "https://github.com/ckeditor/ckeditor5/issues",
25
+ "repository": {
26
+ "type": "git",
27
+ "url": "https://github.com/ckeditor/ckeditor5.git",
28
+ "directory": "packages/ckeditor5-language"
29
+ },
30
+ "files": [
31
+ "dist",
32
+ "lang",
33
+ "src/**/*.js",
34
+ "src/**/*.d.ts",
35
+ "theme",
36
+ "build",
37
+ "ckeditor5-metadata.json",
38
+ "CHANGELOG.md"
39
+ ],
40
+ "types": "src/index.d.ts"
41
+ }
@@ -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
+ import type { TextPartLanguageOption, TextPartLanguage, TextPartLanguageEditing, TextPartLanguageUI, TextPartLanguageCommand } from './index.js';
6
+ declare module '@ckeditor/ckeditor5-core' {
7
+ interface LanguageConfig {
8
+ /**
9
+ * The available {@link module:language/textpartlanguage~TextPartLanguage}
10
+ * options that allow setting the language of parts of the content.
11
+ *
12
+ * This configuration option is available only with the {@glink api/language text part language feature} enabled.
13
+ *
14
+ * Refer to the [WCAG 3.1.2 Language of Parts](https://www.w3.org/TR/UNDERSTANDING-WCAG20/meaning-other-lang-id.html) specification
15
+ * to learn more.
16
+ *
17
+ * To change the editor's UI language, refer to the {@glink getting-started/setup/ui-language Setting the UI language} guide.
18
+ *
19
+ * The default value is:
20
+ *
21
+ * ```ts
22
+ * const config = [
23
+ * { title: 'Arabic', languageCode: 'ar' },
24
+ * { title: 'French', languageCode: 'fr' },
25
+ * { title: 'Spanish', languageCode: 'es' }
26
+ * ];
27
+ * ```
28
+ *
29
+ * The `title` property will be used by the text part language dropdown to render available options.
30
+ *
31
+ * The `languageCode` property is used for the `lang` attribute in the [ISO 639-1](https://en.wikipedia.org/wiki/ISO_639-1) format.
32
+ *
33
+ * You can also specify the optional `textDirection` property indicating the reading direction of the language.
34
+ * Correct values are `ltr` and `rtl`. When the `textDirection` property is missing, the text part language feature will
35
+ * specify the text direction by itself.
36
+ */
37
+ textPartLanguage?: Array<TextPartLanguageOption>;
38
+ }
39
+ interface PluginsMap {
40
+ [TextPartLanguage.pluginName]: TextPartLanguage;
41
+ [TextPartLanguageEditing.pluginName]: TextPartLanguageEditing;
42
+ [TextPartLanguageUI.pluginName]: TextPartLanguageUI;
43
+ }
44
+ interface CommandsMap {
45
+ textPartLanguage: TextPartLanguageCommand;
46
+ }
47
+ }
@@ -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 {};
package/src/index.d.ts ADDED
@@ -0,0 +1,13 @@
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 language
7
+ */
8
+ export { default as TextPartLanguage } from './textpartlanguage.js';
9
+ export { default as TextPartLanguageEditing } from './textpartlanguageediting.js';
10
+ export { default as TextPartLanguageUI } from './textpartlanguageui.js';
11
+ export type { TextPartLanguageOption } from './textpartlanguageconfig.js';
12
+ export type { default as TextPartLanguageCommand } from './textpartlanguagecommand.js';
13
+ import './augmentation.js';
package/src/index.js ADDED
@@ -0,0 +1,11 @@
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 language
7
+ */
8
+ export { default as TextPartLanguage } from './textpartlanguage.js';
9
+ export { default as TextPartLanguageEditing } from './textpartlanguageediting.js';
10
+ export { default as TextPartLanguageUI } from './textpartlanguageui.js';
11
+ import './augmentation.js';
@@ -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
+ * @module language/textpartlanguage
7
+ */
8
+ import { Plugin } from 'ckeditor5/src/core.js';
9
+ import TextPartLanguageEditing from './textpartlanguageediting.js';
10
+ import TextPartLanguageUI from './textpartlanguageui.js';
11
+ /**
12
+ * The text part language feature.
13
+ *
14
+ * This feature allows setting a language of the document's text part to support
15
+ * [WCAG 3.1.2 Language of Parts](https://www.w3.org/TR/UNDERSTANDING-WCAG20/meaning-other-lang-id.html) specification.
16
+ *
17
+ * To change the editor's UI language, refer to the {@glink getting-started/setup/ui-language Setting the UI language} guide.
18
+ *
19
+ * For more information about this feature, check the {@glink api/language package page} as well as the {@glink features/language
20
+ * Text part language} feature guide.
21
+ *
22
+ * This is a "glue" plugin which loads the
23
+ * {@link module:language/textpartlanguageediting~TextPartLanguageEditing text part language editing feature}
24
+ * and the {@link module:language/textpartlanguageui~TextPartLanguageUI text part language UI feature}.
25
+ */
26
+ export default class TextPartLanguage extends Plugin {
27
+ /**
28
+ * @inheritDoc
29
+ */
30
+ static get requires(): readonly [typeof TextPartLanguageEditing, typeof TextPartLanguageUI];
31
+ /**
32
+ * @inheritDoc
33
+ */
34
+ static get pluginName(): "TextPartLanguage";
35
+ /**
36
+ * @inheritDoc
37
+ */
38
+ static get isOfficialPlugin(): true;
39
+ }
@@ -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 language/textpartlanguage
7
+ */
8
+ import { Plugin } from 'ckeditor5/src/core.js';
9
+ import TextPartLanguageEditing from './textpartlanguageediting.js';
10
+ import TextPartLanguageUI from './textpartlanguageui.js';
11
+ /**
12
+ * The text part language feature.
13
+ *
14
+ * This feature allows setting a language of the document's text part to support
15
+ * [WCAG 3.1.2 Language of Parts](https://www.w3.org/TR/UNDERSTANDING-WCAG20/meaning-other-lang-id.html) specification.
16
+ *
17
+ * To change the editor's UI language, refer to the {@glink getting-started/setup/ui-language Setting the UI language} guide.
18
+ *
19
+ * For more information about this feature, check the {@glink api/language package page} as well as the {@glink features/language
20
+ * Text part language} feature guide.
21
+ *
22
+ * This is a "glue" plugin which loads the
23
+ * {@link module:language/textpartlanguageediting~TextPartLanguageEditing text part language editing feature}
24
+ * and the {@link module:language/textpartlanguageui~TextPartLanguageUI text part language UI feature}.
25
+ */
26
+ export default class TextPartLanguage extends Plugin {
27
+ /**
28
+ * @inheritDoc
29
+ */
30
+ static get requires() {
31
+ return [TextPartLanguageEditing, TextPartLanguageUI];
32
+ }
33
+ /**
34
+ * @inheritDoc
35
+ */
36
+ static get pluginName() {
37
+ return 'TextPartLanguage';
38
+ }
39
+ /**
40
+ * @inheritDoc
41
+ */
42
+ static get isOfficialPlugin() {
43
+ return true;
44
+ }
45
+ }
@@ -0,0 +1,70 @@
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 language/textpartlanguagecommand
7
+ */
8
+ import type { LanguageDirection } from 'ckeditor5/src/utils.js';
9
+ import { Command } from 'ckeditor5/src/core.js';
10
+ /**
11
+ * The text part language command plugin.
12
+ */
13
+ export default class TextPartLanguageCommand extends Command {
14
+ /**
15
+ * If the selection starts in a language attribute, the value is set to
16
+ * the value of that language in the following format:
17
+ *
18
+ * ```
19
+ * <languageCode>:<textDirection>
20
+ * ```
21
+ *
22
+ * * `languageCode` - The language code used for the `lang` attribute in the [ISO 639-1](https://en.wikipedia.org/wiki/ISO_639-1)
23
+ * format.
24
+ * * `textDirection` - One of the following values: `rtl` or `ltr`, indicating the reading direction of the language.
25
+ *
26
+ * See the {@link module:core/editor/editorconfig~LanguageConfig#textPartLanguage text part language configuration}
27
+ * for more information about language properties.
28
+ *
29
+ * It is set to `false` otherwise.
30
+ *
31
+ * @observable
32
+ * @readonly
33
+ */
34
+ value: false | string;
35
+ /**
36
+ * @inheritDoc
37
+ */
38
+ refresh(): void;
39
+ /**
40
+ * Executes the command. Applies the attribute to the selection or removes it from the selection.
41
+ *
42
+ * If `languageCode` is set to `false` or a `null` value, it will remove attributes. Otherwise, it will set
43
+ * the attribute in the `{@link #value value}` format.
44
+ *
45
+ * The execution result differs, depending on the {@link module:engine/model/document~Document#selection}:
46
+ *
47
+ * * If the selection is on a range, the command applies the attribute to all nodes in that range
48
+ * (if they are allowed to have this attribute by the {@link module:engine/model/schema~Schema schema}).
49
+ * * If the selection is collapsed in a non-empty node, the command applies the attribute to the
50
+ * {@link module:engine/model/document~Document#selection} itself (note that typed characters copy attributes from the selection).
51
+ * * If the selection is collapsed in an empty node, the command applies the attribute to the parent node of the selection (note
52
+ * that the selection inherits all attributes from a node if it is in an empty node).
53
+ *
54
+ * @fires execute
55
+ * @param options Command options.
56
+ * @param options.languageCode The language code to be applied to the model.
57
+ * @param options.textDirection The language text direction.
58
+ */
59
+ execute({ languageCode, textDirection }?: {
60
+ languageCode?: string | false;
61
+ textDirection?: LanguageDirection;
62
+ }): void;
63
+ /**
64
+ * Returns the attribute value of the first node in the selection that allows the attribute.
65
+ * For a collapsed selection it returns the selection attribute.
66
+ *
67
+ * @returns The attribute value.
68
+ */
69
+ private _getValueFromFirstAllowedNode;
70
+ }
@@ -0,0 +1,89 @@
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 { Command } from 'ckeditor5/src/core.js';
6
+ import { stringifyLanguageAttribute } from './utils.js';
7
+ /**
8
+ * The text part language command plugin.
9
+ */
10
+ export default class TextPartLanguageCommand extends Command {
11
+ /**
12
+ * @inheritDoc
13
+ */
14
+ refresh() {
15
+ const model = this.editor.model;
16
+ const doc = model.document;
17
+ this.value = this._getValueFromFirstAllowedNode();
18
+ this.isEnabled = model.schema.checkAttributeInSelection(doc.selection, 'language');
19
+ }
20
+ /**
21
+ * Executes the command. Applies the attribute to the selection or removes it from the selection.
22
+ *
23
+ * If `languageCode` is set to `false` or a `null` value, it will remove attributes. Otherwise, it will set
24
+ * the attribute in the `{@link #value value}` format.
25
+ *
26
+ * The execution result differs, depending on the {@link module:engine/model/document~Document#selection}:
27
+ *
28
+ * * If the selection is on a range, the command applies the attribute to all nodes in that range
29
+ * (if they are allowed to have this attribute by the {@link module:engine/model/schema~Schema schema}).
30
+ * * If the selection is collapsed in a non-empty node, the command applies the attribute to the
31
+ * {@link module:engine/model/document~Document#selection} itself (note that typed characters copy attributes from the selection).
32
+ * * If the selection is collapsed in an empty node, the command applies the attribute to the parent node of the selection (note
33
+ * that the selection inherits all attributes from a node if it is in an empty node).
34
+ *
35
+ * @fires execute
36
+ * @param options Command options.
37
+ * @param options.languageCode The language code to be applied to the model.
38
+ * @param options.textDirection The language text direction.
39
+ */
40
+ execute({ languageCode, textDirection } = {}) {
41
+ const model = this.editor.model;
42
+ const doc = model.document;
43
+ const selection = doc.selection;
44
+ const value = languageCode ? stringifyLanguageAttribute(languageCode, textDirection) : false;
45
+ model.change(writer => {
46
+ if (selection.isCollapsed) {
47
+ if (value) {
48
+ writer.setSelectionAttribute('language', value);
49
+ }
50
+ else {
51
+ writer.removeSelectionAttribute('language');
52
+ }
53
+ }
54
+ else {
55
+ const ranges = model.schema.getValidRanges(selection.getRanges(), 'language');
56
+ for (const range of ranges) {
57
+ if (value) {
58
+ writer.setAttribute('language', value, range);
59
+ }
60
+ else {
61
+ writer.removeAttribute('language', range);
62
+ }
63
+ }
64
+ }
65
+ });
66
+ }
67
+ /**
68
+ * Returns the attribute value of the first node in the selection that allows the attribute.
69
+ * For a collapsed selection it returns the selection attribute.
70
+ *
71
+ * @returns The attribute value.
72
+ */
73
+ _getValueFromFirstAllowedNode() {
74
+ const model = this.editor.model;
75
+ const schema = model.schema;
76
+ const selection = model.document.selection;
77
+ if (selection.isCollapsed) {
78
+ return selection.getAttribute('language') || false;
79
+ }
80
+ for (const range of selection.getRanges()) {
81
+ for (const item of range.getItems()) {
82
+ if (schema.checkAttribute(item, 'language')) {
83
+ return item.getAttribute('language') || false;
84
+ }
85
+ }
86
+ }
87
+ return false;
88
+ }
89
+ }
@@ -0,0 +1,25 @@
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 language/textpartlanguageconfig
7
+ */
8
+ import type { LanguageDirection } from 'ckeditor5/src/utils.js';
9
+ /**
10
+ * The text part language feature option descriptor.
11
+ */
12
+ export interface TextPartLanguageOption {
13
+ /**
14
+ * The user-readable title of the option.
15
+ */
16
+ title: string;
17
+ /**
18
+ * The language code in the ISO 639 format.
19
+ */
20
+ languageCode: string;
21
+ /**
22
+ * The language text direction. Automatically detected if omitted.
23
+ */
24
+ textDirection?: LanguageDirection;
25
+ }
@@ -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,32 @@
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, type Editor } from 'ckeditor5/src/core.js';
6
+ /**
7
+ * The text part language editing.
8
+ *
9
+ * Introduces the `'textPartLanguage'` command and the `'language'` model element attribute.
10
+ */
11
+ export default class TextPartLanguageEditing extends Plugin {
12
+ /**
13
+ * @inheritDoc
14
+ */
15
+ static get pluginName(): "TextPartLanguageEditing";
16
+ /**
17
+ * @inheritDoc
18
+ */
19
+ static get isOfficialPlugin(): true;
20
+ /**
21
+ * @inheritDoc
22
+ */
23
+ constructor(editor: Editor);
24
+ /**
25
+ * @inheritDoc
26
+ */
27
+ init(): void;
28
+ /**
29
+ * @private
30
+ */
31
+ private _defineConverters;
32
+ }
@@ -0,0 +1,90 @@
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 } from 'ckeditor5/src/core.js';
6
+ import TextPartLanguageCommand from './textpartlanguagecommand.js';
7
+ import { stringifyLanguageAttribute, parseLanguageAttribute } from './utils.js';
8
+ /**
9
+ * The text part language editing.
10
+ *
11
+ * Introduces the `'textPartLanguage'` command and the `'language'` model element attribute.
12
+ */
13
+ export default class TextPartLanguageEditing extends Plugin {
14
+ /**
15
+ * @inheritDoc
16
+ */
17
+ static get pluginName() {
18
+ return 'TextPartLanguageEditing';
19
+ }
20
+ /**
21
+ * @inheritDoc
22
+ */
23
+ static get isOfficialPlugin() {
24
+ return true;
25
+ }
26
+ /**
27
+ * @inheritDoc
28
+ */
29
+ constructor(editor) {
30
+ super(editor);
31
+ // Text part language options are only used to ensure that the feature works by default.
32
+ // In the real usage it should be reconfigured by a developer. We are not providing
33
+ // translations for `title` properties on purpose, as it's only an example configuration.
34
+ editor.config.define('language', {
35
+ textPartLanguage: [
36
+ { title: 'Arabic', languageCode: 'ar' },
37
+ { title: 'French', languageCode: 'fr' },
38
+ { title: 'Spanish', languageCode: 'es' }
39
+ ]
40
+ });
41
+ }
42
+ /**
43
+ * @inheritDoc
44
+ */
45
+ init() {
46
+ const editor = this.editor;
47
+ editor.model.schema.extend('$text', { allowAttributes: 'language' });
48
+ editor.model.schema.setAttributeProperties('language', {
49
+ copyOnEnter: true
50
+ });
51
+ this._defineConverters();
52
+ editor.commands.add('textPartLanguage', new TextPartLanguageCommand(editor));
53
+ }
54
+ /**
55
+ * @private
56
+ */
57
+ _defineConverters() {
58
+ const conversion = this.editor.conversion;
59
+ conversion.for('upcast').elementToAttribute({
60
+ model: {
61
+ key: 'language',
62
+ value: (viewElement) => {
63
+ const languageCode = viewElement.getAttribute('lang');
64
+ const textDirection = viewElement.getAttribute('dir');
65
+ return stringifyLanguageAttribute(languageCode, textDirection);
66
+ }
67
+ },
68
+ view: {
69
+ name: 'span',
70
+ attributes: { lang: /[\s\S]+/ }
71
+ }
72
+ });
73
+ conversion.for('downcast').attributeToElement({
74
+ model: 'language',
75
+ view: (attributeValue, { writer }, data) => {
76
+ if (!attributeValue) {
77
+ return;
78
+ }
79
+ if (!data.item.is('$textProxy') && !data.item.is('documentSelection')) {
80
+ return;
81
+ }
82
+ const { languageCode, textDirection } = parseLanguageAttribute(attributeValue);
83
+ return writer.createAttributeElement('span', {
84
+ lang: languageCode,
85
+ dir: textDirection
86
+ });
87
+ }
88
+ });
89
+ }
90
+ }
@@ -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 language/textpartlanguageui
7
+ */
8
+ import { Plugin } from 'ckeditor5/src/core.js';
9
+ /**
10
+ * The text part language UI plugin.
11
+ *
12
+ * It introduces the `'language'` dropdown.
13
+ */
14
+ export default class TextPartLanguageUI extends Plugin {
15
+ /**
16
+ * @inheritDoc
17
+ */
18
+ static get pluginName(): "TextPartLanguageUI";
19
+ /**
20
+ * @inheritDoc
21
+ */
22
+ static get isOfficialPlugin(): true;
23
+ /**
24
+ * @inheritDoc
25
+ */
26
+ init(): void;
27
+ /**
28
+ * Returns metadata for dropdown and menu items.
29
+ */
30
+ private _getItemMetadata;
31
+ }