@ckeditor/ckeditor5-language 38.1.0 → 38.1.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/build/language.js.map +1 -0
- package/package.json +2 -2
- package/src/augmentation.d.ts +47 -47
- package/src/augmentation.js +5 -5
- package/src/index.d.ts +13 -13
- package/src/index.js +11 -11
- package/src/textpartlanguage.d.ts +35 -35
- package/src/textpartlanguage.js +39 -39
- package/src/textpartlanguagecommand.d.ts +70 -70
- package/src/textpartlanguagecommand.js +89 -89
- package/src/textpartlanguageconfig.d.ts +25 -25
- package/src/textpartlanguageconfig.js +5 -5
- package/src/textpartlanguageediting.d.ts +28 -28
- package/src/textpartlanguageediting.js +84 -84
- package/src/textpartlanguageui.d.ts +23 -23
- package/src/textpartlanguageui.js +101 -101
- package/src/utils.d.ts +40 -40
- package/src/utils.js +43 -43
|
@@ -1,89 +1,89 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license Copyright (c) 2003-2023, 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';
|
|
6
|
-
import { stringifyLanguageAttribute } from './utils';
|
|
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
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2023, 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';
|
|
6
|
+
import { stringifyLanguageAttribute } from './utils';
|
|
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
|
+
}
|
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license Copyright (c) 2003-2023, 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';
|
|
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
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2023, 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';
|
|
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
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license Copyright (c) 2003-2023, 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 {};
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2023, 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 {};
|
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license Copyright (c) 2003-2023, 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';
|
|
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
|
-
constructor(editor: Editor);
|
|
20
|
-
/**
|
|
21
|
-
* @inheritDoc
|
|
22
|
-
*/
|
|
23
|
-
init(): void;
|
|
24
|
-
/**
|
|
25
|
-
* @private
|
|
26
|
-
*/
|
|
27
|
-
private _defineConverters;
|
|
28
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2023, 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';
|
|
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
|
+
constructor(editor: Editor);
|
|
20
|
+
/**
|
|
21
|
+
* @inheritDoc
|
|
22
|
+
*/
|
|
23
|
+
init(): void;
|
|
24
|
+
/**
|
|
25
|
+
* @private
|
|
26
|
+
*/
|
|
27
|
+
private _defineConverters;
|
|
28
|
+
}
|
|
@@ -1,84 +1,84 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license Copyright (c) 2003-2023, 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';
|
|
6
|
-
import TextPartLanguageCommand from './textpartlanguagecommand';
|
|
7
|
-
import { stringifyLanguageAttribute, parseLanguageAttribute } from './utils';
|
|
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
|
-
constructor(editor) {
|
|
24
|
-
super(editor);
|
|
25
|
-
// Text part language options are only used to ensure that the feature works by default.
|
|
26
|
-
// In the real usage it should be reconfigured by a developer. We are not providing
|
|
27
|
-
// translations for `title` properties on purpose, as it's only an example configuration.
|
|
28
|
-
editor.config.define('language', {
|
|
29
|
-
textPartLanguage: [
|
|
30
|
-
{ title: 'Arabic', languageCode: 'ar' },
|
|
31
|
-
{ title: 'French', languageCode: 'fr' },
|
|
32
|
-
{ title: 'Spanish', languageCode: 'es' }
|
|
33
|
-
]
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* @inheritDoc
|
|
38
|
-
*/
|
|
39
|
-
init() {
|
|
40
|
-
const editor = this.editor;
|
|
41
|
-
editor.model.schema.extend('$text', { allowAttributes: 'language' });
|
|
42
|
-
editor.model.schema.setAttributeProperties('language', {
|
|
43
|
-
copyOnEnter: true
|
|
44
|
-
});
|
|
45
|
-
this._defineConverters();
|
|
46
|
-
editor.commands.add('textPartLanguage', new TextPartLanguageCommand(editor));
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
* @private
|
|
50
|
-
*/
|
|
51
|
-
_defineConverters() {
|
|
52
|
-
const conversion = this.editor.conversion;
|
|
53
|
-
conversion.for('upcast').elementToAttribute({
|
|
54
|
-
model: {
|
|
55
|
-
key: 'language',
|
|
56
|
-
value: (viewElement) => {
|
|
57
|
-
const languageCode = viewElement.getAttribute('lang');
|
|
58
|
-
const textDirection = viewElement.getAttribute('dir');
|
|
59
|
-
return stringifyLanguageAttribute(languageCode, textDirection);
|
|
60
|
-
}
|
|
61
|
-
},
|
|
62
|
-
view: {
|
|
63
|
-
name: 'span',
|
|
64
|
-
attributes: { lang: /[\s\S]+/ }
|
|
65
|
-
}
|
|
66
|
-
});
|
|
67
|
-
conversion.for('downcast').attributeToElement({
|
|
68
|
-
model: 'language',
|
|
69
|
-
view: (attributeValue, { writer }, data) => {
|
|
70
|
-
if (!attributeValue) {
|
|
71
|
-
return;
|
|
72
|
-
}
|
|
73
|
-
if (!data.item.is('$textProxy') && !data.item.is('documentSelection')) {
|
|
74
|
-
return;
|
|
75
|
-
}
|
|
76
|
-
const { languageCode, textDirection } = parseLanguageAttribute(attributeValue);
|
|
77
|
-
return writer.createAttributeElement('span', {
|
|
78
|
-
lang: languageCode,
|
|
79
|
-
dir: textDirection
|
|
80
|
-
});
|
|
81
|
-
}
|
|
82
|
-
});
|
|
83
|
-
}
|
|
84
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2023, 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';
|
|
6
|
+
import TextPartLanguageCommand from './textpartlanguagecommand';
|
|
7
|
+
import { stringifyLanguageAttribute, parseLanguageAttribute } from './utils';
|
|
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
|
+
constructor(editor) {
|
|
24
|
+
super(editor);
|
|
25
|
+
// Text part language options are only used to ensure that the feature works by default.
|
|
26
|
+
// In the real usage it should be reconfigured by a developer. We are not providing
|
|
27
|
+
// translations for `title` properties on purpose, as it's only an example configuration.
|
|
28
|
+
editor.config.define('language', {
|
|
29
|
+
textPartLanguage: [
|
|
30
|
+
{ title: 'Arabic', languageCode: 'ar' },
|
|
31
|
+
{ title: 'French', languageCode: 'fr' },
|
|
32
|
+
{ title: 'Spanish', languageCode: 'es' }
|
|
33
|
+
]
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* @inheritDoc
|
|
38
|
+
*/
|
|
39
|
+
init() {
|
|
40
|
+
const editor = this.editor;
|
|
41
|
+
editor.model.schema.extend('$text', { allowAttributes: 'language' });
|
|
42
|
+
editor.model.schema.setAttributeProperties('language', {
|
|
43
|
+
copyOnEnter: true
|
|
44
|
+
});
|
|
45
|
+
this._defineConverters();
|
|
46
|
+
editor.commands.add('textPartLanguage', new TextPartLanguageCommand(editor));
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* @private
|
|
50
|
+
*/
|
|
51
|
+
_defineConverters() {
|
|
52
|
+
const conversion = this.editor.conversion;
|
|
53
|
+
conversion.for('upcast').elementToAttribute({
|
|
54
|
+
model: {
|
|
55
|
+
key: 'language',
|
|
56
|
+
value: (viewElement) => {
|
|
57
|
+
const languageCode = viewElement.getAttribute('lang');
|
|
58
|
+
const textDirection = viewElement.getAttribute('dir');
|
|
59
|
+
return stringifyLanguageAttribute(languageCode, textDirection);
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
view: {
|
|
63
|
+
name: 'span',
|
|
64
|
+
attributes: { lang: /[\s\S]+/ }
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
conversion.for('downcast').attributeToElement({
|
|
68
|
+
model: 'language',
|
|
69
|
+
view: (attributeValue, { writer }, data) => {
|
|
70
|
+
if (!attributeValue) {
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
if (!data.item.is('$textProxy') && !data.item.is('documentSelection')) {
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
const { languageCode, textDirection } = parseLanguageAttribute(attributeValue);
|
|
77
|
+
return writer.createAttributeElement('span', {
|
|
78
|
+
lang: languageCode,
|
|
79
|
+
dir: textDirection
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
}
|
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license Copyright (c) 2003-2023, 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';
|
|
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
|
-
init(): void;
|
|
23
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2023, 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';
|
|
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
|
+
init(): void;
|
|
23
|
+
}
|