@ckeditor/ckeditor5-language 47.6.1 → 48.0.0-alpha.1
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.
- package/ckeditor5-metadata.json +1 -1
- package/dist/index.css +3 -0
- package/dist/index.css.map +1 -0
- package/dist/index.js.map +1 -1
- package/{src → dist}/textpartlanguage.d.ts +1 -1
- package/{src → dist}/textpartlanguagecommand.d.ts +2 -2
- package/{src → dist}/textpartlanguageconfig.d.ts +1 -1
- package/{src → dist}/textpartlanguageediting.d.ts +1 -1
- package/{src → dist}/textpartlanguageui.d.ts +1 -1
- package/{src → dist}/utils.d.ts +1 -1
- package/package.json +22 -45
- package/build/language.js +0 -5
- package/build/translations/af.js +0 -1
- package/build/translations/ar.js +0 -1
- package/build/translations/ast.js +0 -1
- package/build/translations/az.js +0 -1
- package/build/translations/be.js +0 -1
- package/build/translations/bg.js +0 -1
- package/build/translations/bn.js +0 -1
- package/build/translations/bs.js +0 -1
- package/build/translations/ca.js +0 -1
- package/build/translations/cs.js +0 -1
- package/build/translations/da.js +0 -1
- package/build/translations/de-ch.js +0 -1
- package/build/translations/de.js +0 -1
- package/build/translations/el.js +0 -1
- package/build/translations/en-au.js +0 -1
- package/build/translations/en-gb.js +0 -1
- package/build/translations/eo.js +0 -1
- package/build/translations/es-co.js +0 -1
- package/build/translations/es.js +0 -1
- package/build/translations/et.js +0 -1
- package/build/translations/eu.js +0 -1
- package/build/translations/fa.js +0 -1
- package/build/translations/fi.js +0 -1
- package/build/translations/fr.js +0 -1
- package/build/translations/gl.js +0 -1
- package/build/translations/gu.js +0 -1
- package/build/translations/he.js +0 -1
- package/build/translations/hi.js +0 -1
- package/build/translations/hr.js +0 -1
- package/build/translations/hu.js +0 -1
- package/build/translations/hy.js +0 -1
- package/build/translations/id.js +0 -1
- package/build/translations/it.js +0 -1
- package/build/translations/ja.js +0 -1
- package/build/translations/jv.js +0 -1
- package/build/translations/kk.js +0 -1
- package/build/translations/km.js +0 -1
- package/build/translations/kn.js +0 -1
- package/build/translations/ko.js +0 -1
- package/build/translations/ku.js +0 -1
- package/build/translations/lt.js +0 -1
- package/build/translations/lv.js +0 -1
- package/build/translations/ms.js +0 -1
- package/build/translations/nb.js +0 -1
- package/build/translations/ne.js +0 -1
- package/build/translations/nl.js +0 -1
- package/build/translations/no.js +0 -1
- package/build/translations/oc.js +0 -1
- package/build/translations/pl.js +0 -1
- package/build/translations/pt-br.js +0 -1
- package/build/translations/pt.js +0 -1
- package/build/translations/ro.js +0 -1
- package/build/translations/ru.js +0 -1
- package/build/translations/si.js +0 -1
- package/build/translations/sk.js +0 -1
- package/build/translations/sl.js +0 -1
- package/build/translations/sq.js +0 -1
- package/build/translations/sr-latn.js +0 -1
- package/build/translations/sr.js +0 -1
- package/build/translations/sv.js +0 -1
- package/build/translations/th.js +0 -1
- package/build/translations/ti.js +0 -1
- package/build/translations/tk.js +0 -1
- package/build/translations/tr.js +0 -1
- package/build/translations/tt.js +0 -1
- package/build/translations/ug.js +0 -1
- package/build/translations/uk.js +0 -1
- package/build/translations/ur.js +0 -1
- package/build/translations/uz.js +0 -1
- package/build/translations/vi.js +0 -1
- package/build/translations/zh-cn.js +0 -1
- package/build/translations/zh.js +0 -1
- package/lang/contexts.json +0 -5
- package/lang/translations/af.po +0 -24
- package/lang/translations/ar.po +0 -24
- package/lang/translations/ast.po +0 -24
- package/lang/translations/az.po +0 -24
- package/lang/translations/be.po +0 -24
- package/lang/translations/bg.po +0 -24
- package/lang/translations/bn.po +0 -24
- package/lang/translations/bs.po +0 -24
- package/lang/translations/ca.po +0 -24
- package/lang/translations/cs.po +0 -24
- package/lang/translations/da.po +0 -24
- package/lang/translations/de-ch.po +0 -24
- package/lang/translations/de.po +0 -24
- package/lang/translations/el.po +0 -24
- package/lang/translations/en-au.po +0 -24
- package/lang/translations/en-gb.po +0 -24
- package/lang/translations/en.po +0 -24
- package/lang/translations/eo.po +0 -24
- package/lang/translations/es-co.po +0 -24
- package/lang/translations/es.po +0 -24
- package/lang/translations/et.po +0 -24
- package/lang/translations/eu.po +0 -24
- package/lang/translations/fa.po +0 -24
- package/lang/translations/fi.po +0 -24
- package/lang/translations/fr.po +0 -24
- package/lang/translations/gl.po +0 -24
- package/lang/translations/gu.po +0 -24
- package/lang/translations/he.po +0 -24
- package/lang/translations/hi.po +0 -24
- package/lang/translations/hr.po +0 -24
- package/lang/translations/hu.po +0 -24
- package/lang/translations/hy.po +0 -24
- package/lang/translations/id.po +0 -24
- package/lang/translations/it.po +0 -24
- package/lang/translations/ja.po +0 -24
- package/lang/translations/jv.po +0 -24
- package/lang/translations/kk.po +0 -24
- package/lang/translations/km.po +0 -24
- package/lang/translations/kn.po +0 -24
- package/lang/translations/ko.po +0 -24
- package/lang/translations/ku.po +0 -24
- package/lang/translations/lt.po +0 -24
- package/lang/translations/lv.po +0 -24
- package/lang/translations/ms.po +0 -24
- package/lang/translations/nb.po +0 -24
- package/lang/translations/ne.po +0 -24
- package/lang/translations/nl.po +0 -24
- package/lang/translations/no.po +0 -24
- package/lang/translations/oc.po +0 -24
- package/lang/translations/pl.po +0 -24
- package/lang/translations/pt-br.po +0 -24
- package/lang/translations/pt.po +0 -24
- package/lang/translations/ro.po +0 -24
- package/lang/translations/ru.po +0 -24
- package/lang/translations/si.po +0 -24
- package/lang/translations/sk.po +0 -24
- package/lang/translations/sl.po +0 -24
- package/lang/translations/sq.po +0 -24
- package/lang/translations/sr-latn.po +0 -24
- package/lang/translations/sr.po +0 -24
- package/lang/translations/sv.po +0 -24
- package/lang/translations/th.po +0 -24
- package/lang/translations/ti.po +0 -24
- package/lang/translations/tk.po +0 -24
- package/lang/translations/tr.po +0 -24
- package/lang/translations/tt.po +0 -24
- package/lang/translations/ug.po +0 -24
- package/lang/translations/uk.po +0 -24
- package/lang/translations/ur.po +0 -24
- package/lang/translations/uz.po +0 -24
- package/lang/translations/vi.po +0 -24
- package/lang/translations/zh-cn.po +0 -24
- package/lang/translations/zh.po +0 -24
- package/src/augmentation.js +0 -5
- package/src/index.js +0 -13
- package/src/textpartlanguage.js +0 -45
- package/src/textpartlanguagecommand.js +0 -98
- package/src/textpartlanguageconfig.js +0 -5
- package/src/textpartlanguageediting.js +0 -90
- package/src/textpartlanguageui.js +0 -167
- package/src/utils.js +0 -45
- /package/{src → dist}/augmentation.d.ts +0 -0
- /package/{src → dist}/index.d.ts +0 -0
package/lang/translations/ug.po
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
# Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
|
|
2
|
-
#
|
|
3
|
-
# Want to contribute to this file? Submit your changes via a GitHub Pull Request.
|
|
4
|
-
#
|
|
5
|
-
# Check out the official contributor's guide:
|
|
6
|
-
# https://ckeditor.com/docs/ckeditor5/latest/framework/guides/contributing/contributing.html
|
|
7
|
-
#
|
|
8
|
-
msgid ""
|
|
9
|
-
msgstr ""
|
|
10
|
-
"Language: ug\n"
|
|
11
|
-
"Plural-Forms: nplurals=1; plural=0;\n"
|
|
12
|
-
"Content-Type: text/plain; charset=UTF-8\n"
|
|
13
|
-
|
|
14
|
-
msgctxt "Toolbar button tooltip for the text part language feature."
|
|
15
|
-
msgid "Language"
|
|
16
|
-
msgstr "تىل"
|
|
17
|
-
|
|
18
|
-
msgctxt "Default label for the text part language dropdown."
|
|
19
|
-
msgid "Choose language"
|
|
20
|
-
msgstr "تىل تاللاش"
|
|
21
|
-
|
|
22
|
-
msgctxt "The label of the remove language option for the text part language dropdown."
|
|
23
|
-
msgid "Remove language"
|
|
24
|
-
msgstr "تىلنى چىقىرىۋەت"
|
package/lang/translations/uk.po
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
# Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
|
|
2
|
-
#
|
|
3
|
-
# Want to contribute to this file? Submit your changes via a GitHub Pull Request.
|
|
4
|
-
#
|
|
5
|
-
# Check out the official contributor's guide:
|
|
6
|
-
# https://ckeditor.com/docs/ckeditor5/latest/framework/guides/contributing/contributing.html
|
|
7
|
-
#
|
|
8
|
-
msgid ""
|
|
9
|
-
msgstr ""
|
|
10
|
-
"Language: uk\n"
|
|
11
|
-
"Plural-Forms: nplurals=3; plural=(n % 10 == 1 && n % 100 != 11 ? 0 : n % 10 >= 2 && n % 10 <= 4 && (n % 100 < 10 || n % 100 >= 20) ? 1 : 2);\n"
|
|
12
|
-
"Content-Type: text/plain; charset=UTF-8\n"
|
|
13
|
-
|
|
14
|
-
msgctxt "Toolbar button tooltip for the text part language feature."
|
|
15
|
-
msgid "Language"
|
|
16
|
-
msgstr "Мова"
|
|
17
|
-
|
|
18
|
-
msgctxt "Default label for the text part language dropdown."
|
|
19
|
-
msgid "Choose language"
|
|
20
|
-
msgstr "Обрати мову"
|
|
21
|
-
|
|
22
|
-
msgctxt "The label of the remove language option for the text part language dropdown."
|
|
23
|
-
msgid "Remove language"
|
|
24
|
-
msgstr "Видалити мову"
|
package/lang/translations/ur.po
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
# Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
|
|
2
|
-
#
|
|
3
|
-
# Want to contribute to this file? Submit your changes via a GitHub Pull Request.
|
|
4
|
-
#
|
|
5
|
-
# Check out the official contributor's guide:
|
|
6
|
-
# https://ckeditor.com/docs/ckeditor5/latest/framework/guides/contributing/contributing.html
|
|
7
|
-
#
|
|
8
|
-
msgid ""
|
|
9
|
-
msgstr ""
|
|
10
|
-
"Language: ur\n"
|
|
11
|
-
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
|
|
12
|
-
"Content-Type: text/plain; charset=UTF-8\n"
|
|
13
|
-
|
|
14
|
-
msgctxt "Toolbar button tooltip for the text part language feature."
|
|
15
|
-
msgid "Language"
|
|
16
|
-
msgstr "زبان"
|
|
17
|
-
|
|
18
|
-
msgctxt "Default label for the text part language dropdown."
|
|
19
|
-
msgid "Choose language"
|
|
20
|
-
msgstr "زبان کا انتخاب"
|
|
21
|
-
|
|
22
|
-
msgctxt "The label of the remove language option for the text part language dropdown."
|
|
23
|
-
msgid "Remove language"
|
|
24
|
-
msgstr "زبان ہٹائیں"
|
package/lang/translations/uz.po
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
# Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
|
|
2
|
-
#
|
|
3
|
-
# Want to contribute to this file? Submit your changes via a GitHub Pull Request.
|
|
4
|
-
#
|
|
5
|
-
# Check out the official contributor's guide:
|
|
6
|
-
# https://ckeditor.com/docs/ckeditor5/latest/framework/guides/contributing/contributing.html
|
|
7
|
-
#
|
|
8
|
-
msgid ""
|
|
9
|
-
msgstr ""
|
|
10
|
-
"Language: uz\n"
|
|
11
|
-
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
|
|
12
|
-
"Content-Type: text/plain; charset=UTF-8\n"
|
|
13
|
-
|
|
14
|
-
msgctxt "Toolbar button tooltip for the text part language feature."
|
|
15
|
-
msgid "Language"
|
|
16
|
-
msgstr ""
|
|
17
|
-
|
|
18
|
-
msgctxt "Default label for the text part language dropdown."
|
|
19
|
-
msgid "Choose language"
|
|
20
|
-
msgstr ""
|
|
21
|
-
|
|
22
|
-
msgctxt "The label of the remove language option for the text part language dropdown."
|
|
23
|
-
msgid "Remove language"
|
|
24
|
-
msgstr ""
|
package/lang/translations/vi.po
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
# Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
|
|
2
|
-
#
|
|
3
|
-
# Want to contribute to this file? Submit your changes via a GitHub Pull Request.
|
|
4
|
-
#
|
|
5
|
-
# Check out the official contributor's guide:
|
|
6
|
-
# https://ckeditor.com/docs/ckeditor5/latest/framework/guides/contributing/contributing.html
|
|
7
|
-
#
|
|
8
|
-
msgid ""
|
|
9
|
-
msgstr ""
|
|
10
|
-
"Language: vi\n"
|
|
11
|
-
"Plural-Forms: nplurals=1; plural=0;\n"
|
|
12
|
-
"Content-Type: text/plain; charset=UTF-8\n"
|
|
13
|
-
|
|
14
|
-
msgctxt "Toolbar button tooltip for the text part language feature."
|
|
15
|
-
msgid "Language"
|
|
16
|
-
msgstr "Ngôn ngữ"
|
|
17
|
-
|
|
18
|
-
msgctxt "Default label for the text part language dropdown."
|
|
19
|
-
msgid "Choose language"
|
|
20
|
-
msgstr "Chọn ngôn ngữ"
|
|
21
|
-
|
|
22
|
-
msgctxt "The label of the remove language option for the text part language dropdown."
|
|
23
|
-
msgid "Remove language"
|
|
24
|
-
msgstr "Xóa ngôn ngữ"
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
# Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
|
|
2
|
-
#
|
|
3
|
-
# Want to contribute to this file? Submit your changes via a GitHub Pull Request.
|
|
4
|
-
#
|
|
5
|
-
# Check out the official contributor's guide:
|
|
6
|
-
# https://ckeditor.com/docs/ckeditor5/latest/framework/guides/contributing/contributing.html
|
|
7
|
-
#
|
|
8
|
-
msgid ""
|
|
9
|
-
msgstr ""
|
|
10
|
-
"Language: zh_CN\n"
|
|
11
|
-
"Plural-Forms: nplurals=1; plural=0;\n"
|
|
12
|
-
"Content-Type: text/plain; charset=UTF-8\n"
|
|
13
|
-
|
|
14
|
-
msgctxt "Toolbar button tooltip for the text part language feature."
|
|
15
|
-
msgid "Language"
|
|
16
|
-
msgstr "语言"
|
|
17
|
-
|
|
18
|
-
msgctxt "Default label for the text part language dropdown."
|
|
19
|
-
msgid "Choose language"
|
|
20
|
-
msgstr "选择语言"
|
|
21
|
-
|
|
22
|
-
msgctxt "The label of the remove language option for the text part language dropdown."
|
|
23
|
-
msgid "Remove language"
|
|
24
|
-
msgstr "移除语言"
|
package/lang/translations/zh.po
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
# Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
|
|
2
|
-
#
|
|
3
|
-
# Want to contribute to this file? Submit your changes via a GitHub Pull Request.
|
|
4
|
-
#
|
|
5
|
-
# Check out the official contributor's guide:
|
|
6
|
-
# https://ckeditor.com/docs/ckeditor5/latest/framework/guides/contributing/contributing.html
|
|
7
|
-
#
|
|
8
|
-
msgid ""
|
|
9
|
-
msgstr ""
|
|
10
|
-
"Language: zh_TW\n"
|
|
11
|
-
"Plural-Forms: nplurals=1; plural=0;\n"
|
|
12
|
-
"Content-Type: text/plain; charset=UTF-8\n"
|
|
13
|
-
|
|
14
|
-
msgctxt "Toolbar button tooltip for the text part language feature."
|
|
15
|
-
msgid "Language"
|
|
16
|
-
msgstr "語言"
|
|
17
|
-
|
|
18
|
-
msgctxt "Default label for the text part language dropdown."
|
|
19
|
-
msgid "Choose language"
|
|
20
|
-
msgstr "選擇語言"
|
|
21
|
-
|
|
22
|
-
msgctxt "The label of the remove language option for the text part language dropdown."
|
|
23
|
-
msgid "Remove language"
|
|
24
|
-
msgstr "移除語言"
|
package/src/augmentation.js
DELETED
package/src/index.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
-
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
|
|
4
|
-
*/
|
|
5
|
-
/**
|
|
6
|
-
* @module language
|
|
7
|
-
*/
|
|
8
|
-
export { TextPartLanguage } from './textpartlanguage.js';
|
|
9
|
-
export { TextPartLanguageEditing } from './textpartlanguageediting.js';
|
|
10
|
-
export { TextPartLanguageUI } from './textpartlanguageui.js';
|
|
11
|
-
export { TextPartLanguageCommand } from './textpartlanguagecommand.js';
|
|
12
|
-
export { stringifyLanguageAttribute as _stringifyLanguageAttribute, parseLanguageAttribute as _parseLanguageAttribute } from './utils.js';
|
|
13
|
-
import './augmentation.js';
|
package/src/textpartlanguage.js
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
-
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
|
|
4
|
-
*/
|
|
5
|
-
/**
|
|
6
|
-
* @module 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 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
|
-
}
|
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
-
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
|
|
4
|
-
*/
|
|
5
|
-
import { Command } from 'ckeditor5/src/core.js';
|
|
6
|
-
import { ModelDocumentSelection } from 'ckeditor5/src/engine.js';
|
|
7
|
-
import { stringifyLanguageAttribute } from './utils.js';
|
|
8
|
-
/**
|
|
9
|
-
* The text part language command plugin.
|
|
10
|
-
*/
|
|
11
|
-
export class TextPartLanguageCommand extends Command {
|
|
12
|
-
/**
|
|
13
|
-
* @inheritDoc
|
|
14
|
-
*/
|
|
15
|
-
refresh() {
|
|
16
|
-
const model = this.editor.model;
|
|
17
|
-
const doc = model.document;
|
|
18
|
-
this.value = this._getValueFromFirstAllowedNode();
|
|
19
|
-
this.isEnabled = model.schema.checkAttributeInSelection(doc.selection, 'language');
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* Executes the command. Applies the attribute to the selection or removes it from the selection.
|
|
23
|
-
*
|
|
24
|
-
* If `languageCode` is set to `false` or a `null` value, it will remove attributes. Otherwise, it will set
|
|
25
|
-
* the attribute in the `{@link #value value}` format.
|
|
26
|
-
*
|
|
27
|
-
* The execution result differs, depending on the {@link module:engine/model/document~ModelDocument#selection}:
|
|
28
|
-
*
|
|
29
|
-
* * If the selection is on a range, the command applies the attribute to all nodes in that range
|
|
30
|
-
* (if they are allowed to have this attribute by the {@link module:engine/model/schema~ModelSchema schema}).
|
|
31
|
-
* * If the selection is collapsed in a non-empty node, the command applies the attribute to the
|
|
32
|
-
* {@link module:engine/model/document~ModelDocument#selection} itself (note that typed characters copy attributes from the selection).
|
|
33
|
-
* * If the selection is collapsed in an empty node, the command applies the attribute to the parent node of the selection (note
|
|
34
|
-
* that the selection inherits all attributes from a node if it is in an empty node).
|
|
35
|
-
*
|
|
36
|
-
* @fires execute
|
|
37
|
-
* @param options Command options.
|
|
38
|
-
* @param options.languageCode The language code to be applied to the model.
|
|
39
|
-
* @param options.textDirection The language text direction.
|
|
40
|
-
*/
|
|
41
|
-
execute({ languageCode, textDirection } = {}) {
|
|
42
|
-
const model = this.editor.model;
|
|
43
|
-
const doc = model.document;
|
|
44
|
-
const selection = doc.selection;
|
|
45
|
-
const value = languageCode ? stringifyLanguageAttribute(languageCode, textDirection) : false;
|
|
46
|
-
model.change(writer => {
|
|
47
|
-
if (selection.isCollapsed) {
|
|
48
|
-
if (value) {
|
|
49
|
-
writer.setSelectionAttribute('language', value);
|
|
50
|
-
}
|
|
51
|
-
else {
|
|
52
|
-
writer.removeSelectionAttribute('language');
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
else {
|
|
56
|
-
const ranges = model.schema.getValidRanges(selection.getRanges(), 'language', {
|
|
57
|
-
includeEmptyRanges: true
|
|
58
|
-
});
|
|
59
|
-
for (const range of ranges) {
|
|
60
|
-
let itemOrRange = range;
|
|
61
|
-
let attributeKey = 'language';
|
|
62
|
-
if (range.isCollapsed) {
|
|
63
|
-
itemOrRange = range.start.parent;
|
|
64
|
-
attributeKey = ModelDocumentSelection._getStoreAttributeKey('language');
|
|
65
|
-
}
|
|
66
|
-
if (value) {
|
|
67
|
-
writer.setAttribute(attributeKey, value, itemOrRange);
|
|
68
|
-
}
|
|
69
|
-
else {
|
|
70
|
-
writer.removeAttribute(attributeKey, itemOrRange);
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
});
|
|
75
|
-
}
|
|
76
|
-
/**
|
|
77
|
-
* Returns the attribute value of the first node in the selection that allows the attribute.
|
|
78
|
-
* For a collapsed selection it returns the selection attribute.
|
|
79
|
-
*
|
|
80
|
-
* @returns The attribute value.
|
|
81
|
-
*/
|
|
82
|
-
_getValueFromFirstAllowedNode() {
|
|
83
|
-
const model = this.editor.model;
|
|
84
|
-
const schema = model.schema;
|
|
85
|
-
const selection = model.document.selection;
|
|
86
|
-
if (selection.isCollapsed) {
|
|
87
|
-
return selection.getAttribute('language') || false;
|
|
88
|
-
}
|
|
89
|
-
for (const range of selection.getRanges()) {
|
|
90
|
-
for (const item of range.getItems()) {
|
|
91
|
-
if (schema.checkAttribute(item, 'language')) {
|
|
92
|
-
return item.getAttribute('language') || false;
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
return false;
|
|
97
|
-
}
|
|
98
|
-
}
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
-
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
|
|
4
|
-
*/
|
|
5
|
-
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 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
|
-
}
|
|
@@ -1,167 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
-
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
|
|
4
|
-
*/
|
|
5
|
-
/**
|
|
6
|
-
* @module language/textpartlanguageui
|
|
7
|
-
*/
|
|
8
|
-
import { Plugin } from 'ckeditor5/src/core.js';
|
|
9
|
-
import { addListToDropdown, createDropdown, ListSeparatorView, MenuBarMenuView, MenuBarMenuListView, MenuBarMenuListItemView, MenuBarMenuListItemButtonView, UIModel } from 'ckeditor5/src/ui.js';
|
|
10
|
-
import { Collection } from 'ckeditor5/src/utils.js';
|
|
11
|
-
import { stringifyLanguageAttribute } from './utils.js';
|
|
12
|
-
/**
|
|
13
|
-
* The text part language UI plugin.
|
|
14
|
-
*
|
|
15
|
-
* It introduces the `'language'` dropdown.
|
|
16
|
-
*/
|
|
17
|
-
export class TextPartLanguageUI extends Plugin {
|
|
18
|
-
/**
|
|
19
|
-
* @inheritDoc
|
|
20
|
-
*/
|
|
21
|
-
static get pluginName() {
|
|
22
|
-
return 'TextPartLanguageUI';
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* @inheritDoc
|
|
26
|
-
*/
|
|
27
|
-
static get isOfficialPlugin() {
|
|
28
|
-
return true;
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* @inheritDoc
|
|
32
|
-
*/
|
|
33
|
-
init() {
|
|
34
|
-
const editor = this.editor;
|
|
35
|
-
const t = editor.t;
|
|
36
|
-
const defaultTitle = t('Choose language');
|
|
37
|
-
const accessibleLabel = t('Language');
|
|
38
|
-
// Register UI component.
|
|
39
|
-
editor.ui.componentFactory.add('textPartLanguage', locale => {
|
|
40
|
-
const { definitions, titles } = this._getItemMetadata();
|
|
41
|
-
const languageCommand = editor.commands.get('textPartLanguage');
|
|
42
|
-
const dropdownView = createDropdown(locale);
|
|
43
|
-
addListToDropdown(dropdownView, definitions, {
|
|
44
|
-
ariaLabel: accessibleLabel,
|
|
45
|
-
role: 'menu'
|
|
46
|
-
});
|
|
47
|
-
dropdownView.buttonView.set({
|
|
48
|
-
ariaLabel: accessibleLabel,
|
|
49
|
-
ariaLabelledBy: undefined,
|
|
50
|
-
isOn: false,
|
|
51
|
-
withText: true,
|
|
52
|
-
tooltip: accessibleLabel
|
|
53
|
-
});
|
|
54
|
-
dropdownView.extendTemplate({
|
|
55
|
-
attributes: {
|
|
56
|
-
class: [
|
|
57
|
-
'ck-text-fragment-language-dropdown'
|
|
58
|
-
]
|
|
59
|
-
}
|
|
60
|
-
});
|
|
61
|
-
dropdownView.bind('isEnabled').to(languageCommand, 'isEnabled');
|
|
62
|
-
dropdownView.buttonView.bind('label').to(languageCommand, 'value', value => {
|
|
63
|
-
return (value && titles[value]) || defaultTitle;
|
|
64
|
-
});
|
|
65
|
-
dropdownView.buttonView.bind('ariaLabel').to(languageCommand, 'value', value => {
|
|
66
|
-
const selectedLanguageTitle = value && titles[value];
|
|
67
|
-
if (!selectedLanguageTitle) {
|
|
68
|
-
return accessibleLabel;
|
|
69
|
-
}
|
|
70
|
-
return `${selectedLanguageTitle}, ${accessibleLabel}`;
|
|
71
|
-
});
|
|
72
|
-
// Execute command when an item from the dropdown is selected.
|
|
73
|
-
this.listenTo(dropdownView, 'execute', evt => {
|
|
74
|
-
languageCommand.execute({
|
|
75
|
-
languageCode: evt.source.languageCode,
|
|
76
|
-
textDirection: evt.source.textDirection
|
|
77
|
-
});
|
|
78
|
-
editor.editing.view.focus();
|
|
79
|
-
});
|
|
80
|
-
return dropdownView;
|
|
81
|
-
});
|
|
82
|
-
// Register menu bar UI component.
|
|
83
|
-
editor.ui.componentFactory.add('menuBar:textPartLanguage', locale => {
|
|
84
|
-
const { definitions } = this._getItemMetadata();
|
|
85
|
-
const languageCommand = editor.commands.get('textPartLanguage');
|
|
86
|
-
const menuView = new MenuBarMenuView(locale);
|
|
87
|
-
menuView.buttonView.set({
|
|
88
|
-
label: accessibleLabel
|
|
89
|
-
});
|
|
90
|
-
const listView = new MenuBarMenuListView(locale);
|
|
91
|
-
listView.set({
|
|
92
|
-
ariaLabel: t('Language'),
|
|
93
|
-
role: 'menu'
|
|
94
|
-
});
|
|
95
|
-
for (const definition of definitions) {
|
|
96
|
-
if (definition.type != 'button') {
|
|
97
|
-
listView.items.add(new ListSeparatorView(locale));
|
|
98
|
-
continue;
|
|
99
|
-
}
|
|
100
|
-
const listItemView = new MenuBarMenuListItemView(locale, menuView);
|
|
101
|
-
const buttonView = new MenuBarMenuListItemButtonView(locale);
|
|
102
|
-
buttonView.set({
|
|
103
|
-
role: 'menuitemradio',
|
|
104
|
-
isToggleable: true
|
|
105
|
-
});
|
|
106
|
-
buttonView.bind(...Object.keys(definition.model)).to(definition.model);
|
|
107
|
-
buttonView.delegate('execute').to(menuView);
|
|
108
|
-
listItemView.children.add(buttonView);
|
|
109
|
-
listView.items.add(listItemView);
|
|
110
|
-
}
|
|
111
|
-
menuView.bind('isEnabled').to(languageCommand, 'isEnabled');
|
|
112
|
-
menuView.panelView.children.add(listView);
|
|
113
|
-
menuView.on('execute', evt => {
|
|
114
|
-
languageCommand.execute({
|
|
115
|
-
languageCode: evt.source.languageCode,
|
|
116
|
-
textDirection: evt.source.textDirection
|
|
117
|
-
});
|
|
118
|
-
editor.editing.view.focus();
|
|
119
|
-
});
|
|
120
|
-
return menuView;
|
|
121
|
-
});
|
|
122
|
-
}
|
|
123
|
-
/**
|
|
124
|
-
* Returns metadata for dropdown and menu items.
|
|
125
|
-
*/
|
|
126
|
-
_getItemMetadata() {
|
|
127
|
-
const editor = this.editor;
|
|
128
|
-
const itemDefinitions = new Collection();
|
|
129
|
-
const titles = {};
|
|
130
|
-
const languageCommand = editor.commands.get('textPartLanguage');
|
|
131
|
-
const options = editor.config.get('language.textPartLanguage');
|
|
132
|
-
const t = editor.locale.t;
|
|
133
|
-
const removeTitle = t('Remove language');
|
|
134
|
-
// Item definition with false `languageCode` will behave as remove lang button.
|
|
135
|
-
itemDefinitions.add({
|
|
136
|
-
type: 'button',
|
|
137
|
-
model: new UIModel({
|
|
138
|
-
label: removeTitle,
|
|
139
|
-
languageCode: false,
|
|
140
|
-
withText: true
|
|
141
|
-
})
|
|
142
|
-
});
|
|
143
|
-
itemDefinitions.add({
|
|
144
|
-
type: 'separator'
|
|
145
|
-
});
|
|
146
|
-
for (const option of options) {
|
|
147
|
-
const def = {
|
|
148
|
-
type: 'button',
|
|
149
|
-
model: new UIModel({
|
|
150
|
-
label: option.title,
|
|
151
|
-
languageCode: option.languageCode,
|
|
152
|
-
role: 'menuitemradio',
|
|
153
|
-
textDirection: option.textDirection,
|
|
154
|
-
withText: true
|
|
155
|
-
})
|
|
156
|
-
};
|
|
157
|
-
const language = stringifyLanguageAttribute(option.languageCode, option.textDirection);
|
|
158
|
-
def.model.bind('isOn').to(languageCommand, 'value', value => value === language);
|
|
159
|
-
itemDefinitions.add(def);
|
|
160
|
-
titles[language] = option.title;
|
|
161
|
-
}
|
|
162
|
-
return {
|
|
163
|
-
definitions: itemDefinitions,
|
|
164
|
-
titles
|
|
165
|
-
};
|
|
166
|
-
}
|
|
167
|
-
}
|
package/src/utils.js
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
-
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
|
|
4
|
-
*/
|
|
5
|
-
/**
|
|
6
|
-
* @module language/utils
|
|
7
|
-
*/
|
|
8
|
-
import { getLanguageDirection } from 'ckeditor5/src/utils.js';
|
|
9
|
-
/**
|
|
10
|
-
* Returns the language attribute value in a human-readable text format:
|
|
11
|
-
*
|
|
12
|
-
* ```
|
|
13
|
-
* <languageCode>:<textDirection>
|
|
14
|
-
* ```
|
|
15
|
-
*
|
|
16
|
-
* * `languageCode` - The language code used for the `lang` attribute in the [ISO 639-1](https://en.wikipedia.org/wiki/ISO_639-1) format.
|
|
17
|
-
* * `textDirection` - One of the following values: `rtl` or `ltr`, indicating the reading direction of the language.
|
|
18
|
-
*
|
|
19
|
-
* See the {@link module:core/editor/editorconfig~LanguageConfig#textPartLanguage text part language configuration}
|
|
20
|
-
* for more information about language properties.
|
|
21
|
-
*
|
|
22
|
-
* If the `textDirection` argument is omitted, it will be automatically detected based on `languageCode`.
|
|
23
|
-
*
|
|
24
|
-
* @param languageCode The language code in the ISO 639-1 format.
|
|
25
|
-
* @param textDirection The language text direction. Automatically detected if omitted.
|
|
26
|
-
* @internal
|
|
27
|
-
*/
|
|
28
|
-
export function stringifyLanguageAttribute(languageCode, textDirection) {
|
|
29
|
-
textDirection = textDirection || getLanguageDirection(languageCode);
|
|
30
|
-
return `${languageCode}:${textDirection}`;
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* Retrieves language properties converted to attribute value by the
|
|
34
|
-
* {@link module:language/utils~stringifyLanguageAttribute stringifyLanguageAttribute} function.
|
|
35
|
-
*
|
|
36
|
-
* @internal
|
|
37
|
-
* @param str The attribute value.
|
|
38
|
-
* @returns The object with properties:
|
|
39
|
-
* * languageCode - The language code in the ISO 639 format.
|
|
40
|
-
* * textDirection - The language text direction.
|
|
41
|
-
*/
|
|
42
|
-
export function parseLanguageAttribute(str) {
|
|
43
|
-
const [languageCode, textDirection] = str.split(':');
|
|
44
|
-
return { languageCode, textDirection };
|
|
45
|
-
}
|
|
File without changes
|
/package/{src → dist}/index.d.ts
RENAMED
|
File without changes
|