@ckeditor/ckeditor5-special-characters 36.0.0 → 37.0.0-alpha.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.
- package/build/special-characters.js +1 -1
- package/package.json +20 -15
- package/src/index.d.ts +14 -0
- package/src/index.js +0 -2
- package/src/specialcharacters.d.ts +101 -0
- package/src/specialcharacters.js +182 -330
- package/src/specialcharactersarrows.d.ts +35 -0
- package/src/specialcharactersarrows.js +46 -50
- package/src/specialcharactersconfig.d.ts +61 -0
- package/src/specialcharactersconfig.js +5 -0
- package/src/specialcharacterscurrency.d.ts +35 -0
- package/src/specialcharacterscurrency.js +60 -64
- package/src/specialcharactersessentials.d.ts +35 -0
- package/src/specialcharactersessentials.js +26 -24
- package/src/specialcharacterslatin.d.ts +35 -0
- package/src/specialcharacterslatin.js +152 -156
- package/src/specialcharactersmathematical.d.ts +35 -0
- package/src/specialcharactersmathematical.js +68 -72
- package/src/specialcharacterstext.d.ts +35 -0
- package/src/specialcharacterstext.js +51 -55
- package/src/ui/charactergridview.d.ts +53 -0
- package/src/ui/charactergridview.js +138 -186
- package/src/ui/characterinfoview.d.ts +35 -0
- package/src/ui/characterinfoview.js +58 -98
- package/src/ui/specialcharactersnavigationview.d.ts +59 -0
- package/src/ui/specialcharactersnavigationview.js +74 -121
- package/src/ui/specialcharactersview.d.ts +65 -0
- package/src/ui/specialcharactersview.js +60 -125
|
@@ -2,110 +2,70 @@
|
|
|
2
2
|
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
3
|
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
4
|
*/
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* @module special-characters/ui/characterinfoview
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
5
|
import { View } from 'ckeditor5/src/ui';
|
|
11
|
-
|
|
12
6
|
import '../../theme/characterinfo.css';
|
|
13
|
-
|
|
14
7
|
/**
|
|
15
8
|
* The view displaying detailed information about a special character glyph, e.g. upon
|
|
16
9
|
* hovering it with a mouse.
|
|
17
|
-
*
|
|
18
|
-
* @extends module:ui/view~View
|
|
19
10
|
*/
|
|
20
11
|
export default class CharacterInfoView extends View {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
// Note: ZWSP to prevent vertical collapsing.
|
|
67
|
-
text: bind.to( 'name', name => name ? name : '\u200B' )
|
|
68
|
-
}
|
|
69
|
-
]
|
|
70
|
-
},
|
|
71
|
-
{
|
|
72
|
-
tag: 'span',
|
|
73
|
-
attributes: {
|
|
74
|
-
class: [
|
|
75
|
-
'ck-character-info__code'
|
|
76
|
-
]
|
|
77
|
-
},
|
|
78
|
-
children: [
|
|
79
|
-
{
|
|
80
|
-
text: bind.to( 'code' )
|
|
81
|
-
}
|
|
82
|
-
]
|
|
83
|
-
}
|
|
84
|
-
],
|
|
85
|
-
attributes: {
|
|
86
|
-
class: [
|
|
87
|
-
'ck',
|
|
88
|
-
'ck-character-info'
|
|
89
|
-
]
|
|
90
|
-
}
|
|
91
|
-
} );
|
|
92
|
-
}
|
|
12
|
+
constructor(locale) {
|
|
13
|
+
super(locale);
|
|
14
|
+
const bind = this.bindTemplate;
|
|
15
|
+
this.set('character', null);
|
|
16
|
+
this.set('name', null);
|
|
17
|
+
this.bind('code').to(this, 'character', characterToUnicodeString);
|
|
18
|
+
this.setTemplate({
|
|
19
|
+
tag: 'div',
|
|
20
|
+
children: [
|
|
21
|
+
{
|
|
22
|
+
tag: 'span',
|
|
23
|
+
attributes: {
|
|
24
|
+
class: [
|
|
25
|
+
'ck-character-info__name'
|
|
26
|
+
]
|
|
27
|
+
},
|
|
28
|
+
children: [
|
|
29
|
+
{
|
|
30
|
+
// Note: ZWSP to prevent vertical collapsing.
|
|
31
|
+
text: bind.to('name', name => name ? name : '\u200B')
|
|
32
|
+
}
|
|
33
|
+
]
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
tag: 'span',
|
|
37
|
+
attributes: {
|
|
38
|
+
class: [
|
|
39
|
+
'ck-character-info__code'
|
|
40
|
+
]
|
|
41
|
+
},
|
|
42
|
+
children: [
|
|
43
|
+
{
|
|
44
|
+
text: bind.to('code')
|
|
45
|
+
}
|
|
46
|
+
]
|
|
47
|
+
}
|
|
48
|
+
],
|
|
49
|
+
attributes: {
|
|
50
|
+
class: [
|
|
51
|
+
'ck',
|
|
52
|
+
'ck-character-info'
|
|
53
|
+
]
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
}
|
|
93
57
|
}
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
const hexCode = character.codePointAt( 0 ).toString( 16 );
|
|
109
|
-
|
|
110
|
-
return 'U+' + ( '0000' + hexCode ).slice( -4 );
|
|
58
|
+
/**
|
|
59
|
+
* Converts a character into a "Unicode string", for instance:
|
|
60
|
+
*
|
|
61
|
+
* "$" -> "U+0024"
|
|
62
|
+
*
|
|
63
|
+
* Returns an empty string when the character is `null`.
|
|
64
|
+
*/
|
|
65
|
+
function characterToUnicodeString(character) {
|
|
66
|
+
if (character === null) {
|
|
67
|
+
return '';
|
|
68
|
+
}
|
|
69
|
+
const hexCode = character.codePointAt(0).toString(16);
|
|
70
|
+
return 'U+' + ('0000' + hexCode).slice(-4);
|
|
111
71
|
}
|
|
@@ -0,0 +1,59 @@
|
|
|
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 special-characters/ui/specialcharactersnavigationview
|
|
7
|
+
*/
|
|
8
|
+
import { type Locale } from 'ckeditor5/src/utils';
|
|
9
|
+
import { FormHeaderView, type DropdownView } from 'ckeditor5/src/ui';
|
|
10
|
+
/**
|
|
11
|
+
* A class representing the navigation part of the special characters UI. It is responsible
|
|
12
|
+
* for describing the feature and allowing the user to select a particular character group.
|
|
13
|
+
*/
|
|
14
|
+
export default class SpecialCharactersNavigationView extends FormHeaderView {
|
|
15
|
+
/**
|
|
16
|
+
* A dropdown that allows selecting a group of special characters to be displayed.
|
|
17
|
+
*/
|
|
18
|
+
groupDropdownView: GroupDropdownView;
|
|
19
|
+
/**
|
|
20
|
+
* Creates an instance of the {@link module:special-characters/ui/specialcharactersnavigationview~SpecialCharactersNavigationView}
|
|
21
|
+
* class.
|
|
22
|
+
*
|
|
23
|
+
* @param locale The localization services instance.
|
|
24
|
+
* @param groupNames The names of the character groups and their displayed labels.
|
|
25
|
+
*/
|
|
26
|
+
constructor(locale: Locale, groupNames: GroupNames);
|
|
27
|
+
/**
|
|
28
|
+
* Returns the name of the character group currently selected in the {@link #groupDropdownView}.
|
|
29
|
+
*/
|
|
30
|
+
get currentGroupName(): string;
|
|
31
|
+
/**
|
|
32
|
+
* Focuses the character categories dropdown.
|
|
33
|
+
*/
|
|
34
|
+
focus(): void;
|
|
35
|
+
/**
|
|
36
|
+
* Returns a dropdown that allows selecting character groups.
|
|
37
|
+
*
|
|
38
|
+
* @param groupNames The names of the character groups and their displayed labels.
|
|
39
|
+
*/
|
|
40
|
+
private _createGroupDropdown;
|
|
41
|
+
/**
|
|
42
|
+
* Returns list item definitions to be used in the character group dropdown
|
|
43
|
+
* representing specific character groups.
|
|
44
|
+
*
|
|
45
|
+
* @param dropdown Dropdown view element
|
|
46
|
+
* @param groupNames The names of the character groups and their displayed labels.
|
|
47
|
+
*/
|
|
48
|
+
private _getCharacterGroupListItemDefinitions;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* The names of the character groups and their displayed labels.
|
|
52
|
+
*/
|
|
53
|
+
export type GroupNames = Map<string, string>;
|
|
54
|
+
/**
|
|
55
|
+
* `DropdownView` with additional field for the name of the currectly selected character group.
|
|
56
|
+
*/
|
|
57
|
+
export type GroupDropdownView = DropdownView & {
|
|
58
|
+
value: string;
|
|
59
|
+
};
|
|
@@ -2,134 +2,87 @@
|
|
|
2
2
|
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
3
|
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
4
|
*/
|
|
5
|
-
|
|
6
5
|
/**
|
|
7
6
|
* @module special-characters/ui/specialcharactersnavigationview
|
|
8
7
|
*/
|
|
9
|
-
|
|
10
8
|
import { Collection } from 'ckeditor5/src/utils';
|
|
11
|
-
import {
|
|
12
|
-
|
|
9
|
+
import { addListToDropdown, createDropdown, Model, FormHeaderView } from 'ckeditor5/src/ui';
|
|
13
10
|
/**
|
|
14
11
|
* A class representing the navigation part of the special characters UI. It is responsible
|
|
15
12
|
* for describing the feature and allowing the user to select a particular character group.
|
|
16
|
-
*
|
|
17
|
-
* @extends module:ui/formheader/formheaderview~FormHeaderView
|
|
18
13
|
*/
|
|
19
14
|
export default class SpecialCharactersNavigationView extends FormHeaderView {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
dropdown.on( 'execute', evt => {
|
|
94
|
-
dropdown.value = evt.source.name;
|
|
95
|
-
} );
|
|
96
|
-
|
|
97
|
-
dropdown.delegate( 'execute' ).to( this );
|
|
98
|
-
|
|
99
|
-
addListToDropdown( dropdown, groupDefinitions );
|
|
100
|
-
|
|
101
|
-
return dropdown;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
/**
|
|
105
|
-
* Returns list item definitions to be used in the character group dropdown
|
|
106
|
-
* representing specific character groups.
|
|
107
|
-
*
|
|
108
|
-
* @private
|
|
109
|
-
* @param {module:ui/dropdown/dropdownview~DropdownView} dropdown
|
|
110
|
-
* @param {Map.<String, String>} groupNames The names of the character groups and their displayed labels.
|
|
111
|
-
* @returns {Iterable.<module:ui/dropdown/utils~ListDropdownItemDefinition>}
|
|
112
|
-
*/
|
|
113
|
-
_getCharacterGroupListItemDefinitions( dropdown, groupNames ) {
|
|
114
|
-
const groupDefs = new Collection();
|
|
115
|
-
|
|
116
|
-
for ( const [ name, label ] of groupNames ) {
|
|
117
|
-
const definition = {
|
|
118
|
-
type: 'button',
|
|
119
|
-
model: new Model( {
|
|
120
|
-
name,
|
|
121
|
-
label,
|
|
122
|
-
withText: true
|
|
123
|
-
} )
|
|
124
|
-
};
|
|
125
|
-
|
|
126
|
-
definition.model.bind( 'isOn' ).to( dropdown, 'value', value => {
|
|
127
|
-
return value === definition.model.name;
|
|
128
|
-
} );
|
|
129
|
-
|
|
130
|
-
groupDefs.add( definition );
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
return groupDefs;
|
|
134
|
-
}
|
|
15
|
+
/**
|
|
16
|
+
* Creates an instance of the {@link module:special-characters/ui/specialcharactersnavigationview~SpecialCharactersNavigationView}
|
|
17
|
+
* class.
|
|
18
|
+
*
|
|
19
|
+
* @param locale The localization services instance.
|
|
20
|
+
* @param groupNames The names of the character groups and their displayed labels.
|
|
21
|
+
*/
|
|
22
|
+
constructor(locale, groupNames) {
|
|
23
|
+
super(locale);
|
|
24
|
+
const t = locale.t;
|
|
25
|
+
this.set('class', 'ck-special-characters-navigation');
|
|
26
|
+
this.groupDropdownView = this._createGroupDropdown(groupNames);
|
|
27
|
+
this.groupDropdownView.panelPosition = locale.uiLanguageDirection === 'rtl' ? 'se' : 'sw';
|
|
28
|
+
this.label = t('Special characters');
|
|
29
|
+
this.children.add(this.groupDropdownView);
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Returns the name of the character group currently selected in the {@link #groupDropdownView}.
|
|
33
|
+
*/
|
|
34
|
+
get currentGroupName() {
|
|
35
|
+
return this.groupDropdownView.value;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Focuses the character categories dropdown.
|
|
39
|
+
*/
|
|
40
|
+
focus() {
|
|
41
|
+
this.groupDropdownView.focus();
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Returns a dropdown that allows selecting character groups.
|
|
45
|
+
*
|
|
46
|
+
* @param groupNames The names of the character groups and their displayed labels.
|
|
47
|
+
*/
|
|
48
|
+
_createGroupDropdown(groupNames) {
|
|
49
|
+
const locale = this.locale;
|
|
50
|
+
const t = locale.t;
|
|
51
|
+
const dropdown = createDropdown(locale);
|
|
52
|
+
const groupDefinitions = this._getCharacterGroupListItemDefinitions(dropdown, groupNames);
|
|
53
|
+
dropdown.set('value', groupDefinitions.first.model.name);
|
|
54
|
+
dropdown.buttonView.bind('label').to(dropdown, 'value', value => groupNames.get(value));
|
|
55
|
+
dropdown.buttonView.set({
|
|
56
|
+
isOn: false,
|
|
57
|
+
withText: true,
|
|
58
|
+
tooltip: t('Character categories'),
|
|
59
|
+
class: ['ck-dropdown__button_label-width_auto']
|
|
60
|
+
});
|
|
61
|
+
dropdown.on('execute', evt => {
|
|
62
|
+
dropdown.value = evt.source.name;
|
|
63
|
+
});
|
|
64
|
+
dropdown.delegate('execute').to(this);
|
|
65
|
+
addListToDropdown(dropdown, groupDefinitions);
|
|
66
|
+
return dropdown;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Returns list item definitions to be used in the character group dropdown
|
|
70
|
+
* representing specific character groups.
|
|
71
|
+
*
|
|
72
|
+
* @param dropdown Dropdown view element
|
|
73
|
+
* @param groupNames The names of the character groups and their displayed labels.
|
|
74
|
+
*/
|
|
75
|
+
_getCharacterGroupListItemDefinitions(dropdown, groupNames) {
|
|
76
|
+
const groupDefs = new Collection();
|
|
77
|
+
for (const [name, label] of groupNames) {
|
|
78
|
+
const model = new Model({
|
|
79
|
+
name,
|
|
80
|
+
label,
|
|
81
|
+
withText: true
|
|
82
|
+
});
|
|
83
|
+
model.bind('isOn').to(dropdown, 'value', value => value === model.name);
|
|
84
|
+
groupDefs.add({ type: 'button', model });
|
|
85
|
+
}
|
|
86
|
+
return groupDefs;
|
|
87
|
+
}
|
|
135
88
|
}
|
|
@@ -0,0 +1,65 @@
|
|
|
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 special-characters/ui/specialcharactersview
|
|
7
|
+
*/
|
|
8
|
+
import { View, FocusCycler, type ViewCollection } from 'ckeditor5/src/ui';
|
|
9
|
+
import { FocusTracker, KeystrokeHandler, type Locale } from 'ckeditor5/src/utils';
|
|
10
|
+
import type CharacterGridView from './charactergridview';
|
|
11
|
+
import type CharacterInfoView from './characterinfoview';
|
|
12
|
+
import type SpecialCharactersNavigationView from './specialcharactersnavigationview';
|
|
13
|
+
/**
|
|
14
|
+
* A view that glues pieces of the special characters dropdown panel together:
|
|
15
|
+
*
|
|
16
|
+
* * the navigation view (allows selecting the category),
|
|
17
|
+
* * the grid view (displays characters as a grid),
|
|
18
|
+
* * and the info view (displays detailed info about a specific character).
|
|
19
|
+
*/
|
|
20
|
+
export default class SpecialCharactersView extends View<HTMLDivElement> {
|
|
21
|
+
/**
|
|
22
|
+
* A collection of the focusable children of the view.
|
|
23
|
+
*/
|
|
24
|
+
readonly items: ViewCollection;
|
|
25
|
+
/**
|
|
26
|
+
* Tracks information about the DOM focus in the view.
|
|
27
|
+
*/
|
|
28
|
+
readonly focusTracker: FocusTracker;
|
|
29
|
+
/**
|
|
30
|
+
* An instance of the {@link module:utils/keystrokehandler~KeystrokeHandler}.
|
|
31
|
+
*/
|
|
32
|
+
readonly keystrokes: KeystrokeHandler;
|
|
33
|
+
/**
|
|
34
|
+
* Helps cycling over focusable {@link #items} in the view.
|
|
35
|
+
*/
|
|
36
|
+
protected readonly _focusCycler: FocusCycler;
|
|
37
|
+
/**
|
|
38
|
+
* An instance of the `SpecialCharactersNavigationView`.
|
|
39
|
+
*/
|
|
40
|
+
navigationView: SpecialCharactersNavigationView;
|
|
41
|
+
/**
|
|
42
|
+
* An instance of the `CharacterGridView`.
|
|
43
|
+
*/
|
|
44
|
+
gridView: CharacterGridView;
|
|
45
|
+
/**
|
|
46
|
+
* An instance of the `CharacterInfoView`.
|
|
47
|
+
*/
|
|
48
|
+
infoView: CharacterInfoView;
|
|
49
|
+
/**
|
|
50
|
+
* Creates an instance of the `SpecialCharactersView`.
|
|
51
|
+
*/
|
|
52
|
+
constructor(locale: Locale, navigationView: SpecialCharactersNavigationView, gridView: CharacterGridView, infoView: CharacterInfoView);
|
|
53
|
+
/**
|
|
54
|
+
* @inheritDoc
|
|
55
|
+
*/
|
|
56
|
+
render(): void;
|
|
57
|
+
/**
|
|
58
|
+
* @inheritDoc
|
|
59
|
+
*/
|
|
60
|
+
destroy(): void;
|
|
61
|
+
/**
|
|
62
|
+
* Focuses the first focusable in {@link #items}.
|
|
63
|
+
*/
|
|
64
|
+
focus(): void;
|
|
65
|
+
}
|