@ckeditor/ckeditor5-special-characters 39.0.2 → 40.0.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.map +1 -0
- package/build/translations/pt-br.js +1 -1
- package/lang/translations/pt-br.po +41 -41
- package/package.json +2 -2
- package/src/augmentation.d.ts +24 -24
- package/src/augmentation.js +5 -5
- package/src/index.d.ts +16 -16
- package/src/index.js +15 -15
- package/src/specialcharacters.d.ts +96 -96
- package/src/specialcharacters.js +206 -206
- package/src/specialcharactersarrows.d.ts +30 -30
- package/src/specialcharactersarrows.js +60 -60
- package/src/specialcharactersconfig.d.ts +51 -51
- package/src/specialcharactersconfig.js +5 -5
- package/src/specialcharacterscurrency.d.ts +30 -30
- package/src/specialcharacterscurrency.js +74 -74
- package/src/specialcharactersessentials.d.ts +35 -35
- package/src/specialcharactersessentials.js +45 -45
- package/src/specialcharacterslatin.d.ts +30 -30
- package/src/specialcharacterslatin.js +166 -166
- package/src/specialcharactersmathematical.d.ts +30 -30
- package/src/specialcharactersmathematical.js +82 -82
- package/src/specialcharacterstext.d.ts +30 -30
- package/src/specialcharacterstext.js +65 -65
- package/src/ui/charactergridview.d.ts +94 -94
- package/src/ui/charactergridview.js +129 -129
- package/src/ui/characterinfoview.d.ts +35 -35
- package/src/ui/characterinfoview.js +71 -71
- package/src/ui/specialcharactersnavigationview.d.ts +59 -59
- package/src/ui/specialcharactersnavigationview.js +95 -95
- package/src/ui/specialcharactersview.d.ts +65 -65
- package/src/ui/specialcharactersview.js +78 -78
|
@@ -1,65 +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/specialcharacterstext
|
|
7
|
-
*/
|
|
8
|
-
import { Plugin } from 'ckeditor5/src/core';
|
|
9
|
-
/**
|
|
10
|
-
* A plugin that provides special characters for the "Text" category.
|
|
11
|
-
*
|
|
12
|
-
* ```ts
|
|
13
|
-
* ClassicEditor
|
|
14
|
-
* .create( {
|
|
15
|
-
* plugins: [ ..., SpecialCharacters, SpecialCharactersText ],
|
|
16
|
-
* } )
|
|
17
|
-
* .then( ... )
|
|
18
|
-
* .catch( ... );
|
|
19
|
-
* ```
|
|
20
|
-
*/
|
|
21
|
-
export default class SpecialCharactersText extends Plugin {
|
|
22
|
-
/**
|
|
23
|
-
* @inheritDoc
|
|
24
|
-
*/
|
|
25
|
-
static get pluginName() {
|
|
26
|
-
return 'SpecialCharactersText';
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* @inheritDoc
|
|
30
|
-
*/
|
|
31
|
-
init() {
|
|
32
|
-
const editor = this.editor;
|
|
33
|
-
const t = editor.t;
|
|
34
|
-
const plugin = editor.plugins.get('SpecialCharacters');
|
|
35
|
-
plugin.addItems('Text', [
|
|
36
|
-
{ character: '‹', title: t('Single left-pointing angle quotation mark') },
|
|
37
|
-
{ character: '›', title: t('Single right-pointing angle quotation mark') },
|
|
38
|
-
{ character: '«', title: t('Left-pointing double angle quotation mark') },
|
|
39
|
-
{ character: '»', title: t('Right-pointing double angle quotation mark') },
|
|
40
|
-
{ character: '‘', title: t('Left single quotation mark') },
|
|
41
|
-
{ character: '’', title: t('Right single quotation mark') },
|
|
42
|
-
{ character: '“', title: t('Left double quotation mark') },
|
|
43
|
-
{ character: '”', title: t('Right double quotation mark') },
|
|
44
|
-
{ character: '‚', title: t('Single low-9 quotation mark') },
|
|
45
|
-
{ character: '„', title: t('Double low-9 quotation mark') },
|
|
46
|
-
{ character: '¡', title: t('Inverted exclamation mark') },
|
|
47
|
-
{ character: '¿', title: t('Inverted question mark') },
|
|
48
|
-
{ character: '‥', title: t('Two dot leader') },
|
|
49
|
-
{ character: '…', title: t('Horizontal ellipsis') },
|
|
50
|
-
{ character: '‡', title: t('Double dagger') },
|
|
51
|
-
{ character: '‰', title: t('Per mille sign') },
|
|
52
|
-
{ character: '‱', title: t('Per ten thousand sign') },
|
|
53
|
-
{ character: '‼', title: t('Double exclamation mark') },
|
|
54
|
-
{ character: '⁈', title: t('Question exclamation mark') },
|
|
55
|
-
{ character: '⁉', title: t('Exclamation question mark') },
|
|
56
|
-
{ character: '⁇', title: t('Double question mark') },
|
|
57
|
-
{ character: '©', title: t('Copyright sign') },
|
|
58
|
-
{ character: '®', title: t('Registered sign') },
|
|
59
|
-
{ character: '™', title: t('Trade mark sign') },
|
|
60
|
-
{ character: '§', title: t('Section sign') },
|
|
61
|
-
{ character: '¶', title: t('Paragraph sign') },
|
|
62
|
-
{ character: '⁋', title: t('Reversed paragraph sign') }
|
|
63
|
-
], { label: t('Text') });
|
|
64
|
-
}
|
|
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/specialcharacterstext
|
|
7
|
+
*/
|
|
8
|
+
import { Plugin } from 'ckeditor5/src/core';
|
|
9
|
+
/**
|
|
10
|
+
* A plugin that provides special characters for the "Text" category.
|
|
11
|
+
*
|
|
12
|
+
* ```ts
|
|
13
|
+
* ClassicEditor
|
|
14
|
+
* .create( {
|
|
15
|
+
* plugins: [ ..., SpecialCharacters, SpecialCharactersText ],
|
|
16
|
+
* } )
|
|
17
|
+
* .then( ... )
|
|
18
|
+
* .catch( ... );
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
export default class SpecialCharactersText extends Plugin {
|
|
22
|
+
/**
|
|
23
|
+
* @inheritDoc
|
|
24
|
+
*/
|
|
25
|
+
static get pluginName() {
|
|
26
|
+
return 'SpecialCharactersText';
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* @inheritDoc
|
|
30
|
+
*/
|
|
31
|
+
init() {
|
|
32
|
+
const editor = this.editor;
|
|
33
|
+
const t = editor.t;
|
|
34
|
+
const plugin = editor.plugins.get('SpecialCharacters');
|
|
35
|
+
plugin.addItems('Text', [
|
|
36
|
+
{ character: '‹', title: t('Single left-pointing angle quotation mark') },
|
|
37
|
+
{ character: '›', title: t('Single right-pointing angle quotation mark') },
|
|
38
|
+
{ character: '«', title: t('Left-pointing double angle quotation mark') },
|
|
39
|
+
{ character: '»', title: t('Right-pointing double angle quotation mark') },
|
|
40
|
+
{ character: '‘', title: t('Left single quotation mark') },
|
|
41
|
+
{ character: '’', title: t('Right single quotation mark') },
|
|
42
|
+
{ character: '“', title: t('Left double quotation mark') },
|
|
43
|
+
{ character: '”', title: t('Right double quotation mark') },
|
|
44
|
+
{ character: '‚', title: t('Single low-9 quotation mark') },
|
|
45
|
+
{ character: '„', title: t('Double low-9 quotation mark') },
|
|
46
|
+
{ character: '¡', title: t('Inverted exclamation mark') },
|
|
47
|
+
{ character: '¿', title: t('Inverted question mark') },
|
|
48
|
+
{ character: '‥', title: t('Two dot leader') },
|
|
49
|
+
{ character: '…', title: t('Horizontal ellipsis') },
|
|
50
|
+
{ character: '‡', title: t('Double dagger') },
|
|
51
|
+
{ character: '‰', title: t('Per mille sign') },
|
|
52
|
+
{ character: '‱', title: t('Per ten thousand sign') },
|
|
53
|
+
{ character: '‼', title: t('Double exclamation mark') },
|
|
54
|
+
{ character: '⁈', title: t('Question exclamation mark') },
|
|
55
|
+
{ character: '⁉', title: t('Exclamation question mark') },
|
|
56
|
+
{ character: '⁇', title: t('Double question mark') },
|
|
57
|
+
{ character: '©', title: t('Copyright sign') },
|
|
58
|
+
{ character: '®', title: t('Registered sign') },
|
|
59
|
+
{ character: '™', title: t('Trade mark sign') },
|
|
60
|
+
{ character: '§', title: t('Section sign') },
|
|
61
|
+
{ character: '¶', title: t('Paragraph sign') },
|
|
62
|
+
{ character: '⁋', title: t('Reversed paragraph sign') }
|
|
63
|
+
], { label: t('Text') });
|
|
64
|
+
}
|
|
65
|
+
}
|
|
@@ -1,94 +1,94 @@
|
|
|
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/charactergridview
|
|
7
|
-
*/
|
|
8
|
-
import { View, ButtonView, type ViewCollection } from 'ckeditor5/src/ui';
|
|
9
|
-
import { KeystrokeHandler, FocusTracker, type Locale } from 'ckeditor5/src/utils';
|
|
10
|
-
import '../../theme/charactergrid.css';
|
|
11
|
-
/**
|
|
12
|
-
* A grid of character tiles. It allows browsing special characters and selecting the character to
|
|
13
|
-
* be inserted into the content.
|
|
14
|
-
*/
|
|
15
|
-
export default class CharacterGridView extends View<HTMLDivElement> {
|
|
16
|
-
/**
|
|
17
|
-
* A collection of the child tile views. Each tile represents a particular character.
|
|
18
|
-
*/
|
|
19
|
-
readonly tiles: ViewCollection<ButtonView>;
|
|
20
|
-
/**
|
|
21
|
-
* Tracks information about the DOM focus in the grid.
|
|
22
|
-
*/
|
|
23
|
-
readonly focusTracker: FocusTracker;
|
|
24
|
-
/**
|
|
25
|
-
* An instance of the {@link module:utils/keystrokehandler~KeystrokeHandler}.
|
|
26
|
-
*/
|
|
27
|
-
readonly keystrokes: KeystrokeHandler;
|
|
28
|
-
/**
|
|
29
|
-
* Creates an instance of a character grid containing tiles representing special characters.
|
|
30
|
-
*
|
|
31
|
-
* @param locale The localization services instance.
|
|
32
|
-
*/
|
|
33
|
-
constructor(locale: Locale);
|
|
34
|
-
/**
|
|
35
|
-
* Creates a new tile for the grid.
|
|
36
|
-
*
|
|
37
|
-
* @param character A human-readable character displayed as the label (e.g. "ε").
|
|
38
|
-
* @param name The name of the character (e.g. "greek small letter epsilon").
|
|
39
|
-
*/
|
|
40
|
-
createTile(character: string, name: string): ButtonView;
|
|
41
|
-
/**
|
|
42
|
-
* @inheritDoc
|
|
43
|
-
*/
|
|
44
|
-
render(): void;
|
|
45
|
-
/**
|
|
46
|
-
* @inheritDoc
|
|
47
|
-
*/
|
|
48
|
-
destroy(): void;
|
|
49
|
-
/**
|
|
50
|
-
* Focuses the first focusable in {@link ~CharacterGridView#tiles}.
|
|
51
|
-
*/
|
|
52
|
-
focus(): void;
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* Fired when any of {@link ~CharacterGridView#tiles grid tiles} is clicked.
|
|
56
|
-
*
|
|
57
|
-
* @eventName ~CharacterGridView#execute
|
|
58
|
-
* @param data Additional information about the event.
|
|
59
|
-
*/
|
|
60
|
-
export type CharacterGridViewExecuteEvent = {
|
|
61
|
-
name: 'execute';
|
|
62
|
-
args: [data: CharacterGridViewEventData];
|
|
63
|
-
};
|
|
64
|
-
/**
|
|
65
|
-
* Fired when a mouse or another pointing device caused the cursor to move onto any {@link ~CharacterGridView#tiles grid tile}
|
|
66
|
-
* (similar to the native `mouseover` DOM event).
|
|
67
|
-
*
|
|
68
|
-
* @eventName ~CharacterGridView#tileHover
|
|
69
|
-
* @param data Additional information about the event.
|
|
70
|
-
*/
|
|
71
|
-
export type CharacterGridViewTileHoverEvent = {
|
|
72
|
-
name: 'tileHover';
|
|
73
|
-
args: [data: CharacterGridViewEventData];
|
|
74
|
-
};
|
|
75
|
-
/**
|
|
76
|
-
* Fired when {@link ~CharacterGridView#tiles grid tile} is focused (e.g. by navigating with arrow keys).
|
|
77
|
-
*
|
|
78
|
-
* @eventName ~CharacterGridView#tileFocus
|
|
79
|
-
* @param data Additional information about the event.
|
|
80
|
-
*/
|
|
81
|
-
export type CharacterGridViewTileFocusEvent = {
|
|
82
|
-
name: 'tileFocus';
|
|
83
|
-
args: [data: CharacterGridViewEventData];
|
|
84
|
-
};
|
|
85
|
-
export interface CharacterGridViewEventData {
|
|
86
|
-
/**
|
|
87
|
-
* The name of the tile that caused the event (e.g. "greek small letter epsilon").
|
|
88
|
-
*/
|
|
89
|
-
name: string;
|
|
90
|
-
/**
|
|
91
|
-
* A human-readable character displayed as the label (e.g. "ε").
|
|
92
|
-
*/
|
|
93
|
-
character: string;
|
|
94
|
-
}
|
|
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/charactergridview
|
|
7
|
+
*/
|
|
8
|
+
import { View, ButtonView, type ViewCollection } from 'ckeditor5/src/ui';
|
|
9
|
+
import { KeystrokeHandler, FocusTracker, type Locale } from 'ckeditor5/src/utils';
|
|
10
|
+
import '../../theme/charactergrid.css';
|
|
11
|
+
/**
|
|
12
|
+
* A grid of character tiles. It allows browsing special characters and selecting the character to
|
|
13
|
+
* be inserted into the content.
|
|
14
|
+
*/
|
|
15
|
+
export default class CharacterGridView extends View<HTMLDivElement> {
|
|
16
|
+
/**
|
|
17
|
+
* A collection of the child tile views. Each tile represents a particular character.
|
|
18
|
+
*/
|
|
19
|
+
readonly tiles: ViewCollection<ButtonView>;
|
|
20
|
+
/**
|
|
21
|
+
* Tracks information about the DOM focus in the grid.
|
|
22
|
+
*/
|
|
23
|
+
readonly focusTracker: FocusTracker;
|
|
24
|
+
/**
|
|
25
|
+
* An instance of the {@link module:utils/keystrokehandler~KeystrokeHandler}.
|
|
26
|
+
*/
|
|
27
|
+
readonly keystrokes: KeystrokeHandler;
|
|
28
|
+
/**
|
|
29
|
+
* Creates an instance of a character grid containing tiles representing special characters.
|
|
30
|
+
*
|
|
31
|
+
* @param locale The localization services instance.
|
|
32
|
+
*/
|
|
33
|
+
constructor(locale: Locale);
|
|
34
|
+
/**
|
|
35
|
+
* Creates a new tile for the grid.
|
|
36
|
+
*
|
|
37
|
+
* @param character A human-readable character displayed as the label (e.g. "ε").
|
|
38
|
+
* @param name The name of the character (e.g. "greek small letter epsilon").
|
|
39
|
+
*/
|
|
40
|
+
createTile(character: string, name: string): ButtonView;
|
|
41
|
+
/**
|
|
42
|
+
* @inheritDoc
|
|
43
|
+
*/
|
|
44
|
+
render(): void;
|
|
45
|
+
/**
|
|
46
|
+
* @inheritDoc
|
|
47
|
+
*/
|
|
48
|
+
destroy(): void;
|
|
49
|
+
/**
|
|
50
|
+
* Focuses the first focusable in {@link ~CharacterGridView#tiles}.
|
|
51
|
+
*/
|
|
52
|
+
focus(): void;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Fired when any of {@link ~CharacterGridView#tiles grid tiles} is clicked.
|
|
56
|
+
*
|
|
57
|
+
* @eventName ~CharacterGridView#execute
|
|
58
|
+
* @param data Additional information about the event.
|
|
59
|
+
*/
|
|
60
|
+
export type CharacterGridViewExecuteEvent = {
|
|
61
|
+
name: 'execute';
|
|
62
|
+
args: [data: CharacterGridViewEventData];
|
|
63
|
+
};
|
|
64
|
+
/**
|
|
65
|
+
* Fired when a mouse or another pointing device caused the cursor to move onto any {@link ~CharacterGridView#tiles grid tile}
|
|
66
|
+
* (similar to the native `mouseover` DOM event).
|
|
67
|
+
*
|
|
68
|
+
* @eventName ~CharacterGridView#tileHover
|
|
69
|
+
* @param data Additional information about the event.
|
|
70
|
+
*/
|
|
71
|
+
export type CharacterGridViewTileHoverEvent = {
|
|
72
|
+
name: 'tileHover';
|
|
73
|
+
args: [data: CharacterGridViewEventData];
|
|
74
|
+
};
|
|
75
|
+
/**
|
|
76
|
+
* Fired when {@link ~CharacterGridView#tiles grid tile} is focused (e.g. by navigating with arrow keys).
|
|
77
|
+
*
|
|
78
|
+
* @eventName ~CharacterGridView#tileFocus
|
|
79
|
+
* @param data Additional information about the event.
|
|
80
|
+
*/
|
|
81
|
+
export type CharacterGridViewTileFocusEvent = {
|
|
82
|
+
name: 'tileFocus';
|
|
83
|
+
args: [data: CharacterGridViewEventData];
|
|
84
|
+
};
|
|
85
|
+
export interface CharacterGridViewEventData {
|
|
86
|
+
/**
|
|
87
|
+
* The name of the tile that caused the event (e.g. "greek small letter epsilon").
|
|
88
|
+
*/
|
|
89
|
+
name: string;
|
|
90
|
+
/**
|
|
91
|
+
* A human-readable character displayed as the label (e.g. "ε").
|
|
92
|
+
*/
|
|
93
|
+
character: string;
|
|
94
|
+
}
|
|
@@ -1,129 +1,129 @@
|
|
|
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/charactergridview
|
|
7
|
-
*/
|
|
8
|
-
import { View, ButtonView, addKeyboardHandlingForGrid } from 'ckeditor5/src/ui';
|
|
9
|
-
import { KeystrokeHandler, FocusTracker, global } from 'ckeditor5/src/utils';
|
|
10
|
-
import '../../theme/charactergrid.css';
|
|
11
|
-
/**
|
|
12
|
-
* A grid of character tiles. It allows browsing special characters and selecting the character to
|
|
13
|
-
* be inserted into the content.
|
|
14
|
-
*/
|
|
15
|
-
export default class CharacterGridView extends View {
|
|
16
|
-
/**
|
|
17
|
-
* Creates an instance of a character grid containing tiles representing special characters.
|
|
18
|
-
*
|
|
19
|
-
* @param locale The localization services instance.
|
|
20
|
-
*/
|
|
21
|
-
constructor(locale) {
|
|
22
|
-
super(locale);
|
|
23
|
-
this.tiles = this.createCollection();
|
|
24
|
-
this.setTemplate({
|
|
25
|
-
tag: 'div',
|
|
26
|
-
children: [
|
|
27
|
-
{
|
|
28
|
-
tag: 'div',
|
|
29
|
-
attributes: {
|
|
30
|
-
class: [
|
|
31
|
-
'ck',
|
|
32
|
-
'ck-character-grid__tiles'
|
|
33
|
-
]
|
|
34
|
-
},
|
|
35
|
-
children: this.tiles
|
|
36
|
-
}
|
|
37
|
-
],
|
|
38
|
-
attributes: {
|
|
39
|
-
class: [
|
|
40
|
-
'ck',
|
|
41
|
-
'ck-character-grid'
|
|
42
|
-
]
|
|
43
|
-
}
|
|
44
|
-
});
|
|
45
|
-
this.focusTracker = new FocusTracker();
|
|
46
|
-
this.keystrokes = new KeystrokeHandler();
|
|
47
|
-
addKeyboardHandlingForGrid({
|
|
48
|
-
keystrokeHandler: this.keystrokes,
|
|
49
|
-
focusTracker: this.focusTracker,
|
|
50
|
-
gridItems: this.tiles,
|
|
51
|
-
numberOfColumns: () => global.window
|
|
52
|
-
.getComputedStyle(this.element.firstChild) // Responsive .ck-character-grid__tiles
|
|
53
|
-
.getPropertyValue('grid-template-columns')
|
|
54
|
-
.split(' ')
|
|
55
|
-
.length,
|
|
56
|
-
uiLanguageDirection: this.locale && this.locale.uiLanguageDirection
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* Creates a new tile for the grid.
|
|
61
|
-
*
|
|
62
|
-
* @param character A human-readable character displayed as the label (e.g. "ε").
|
|
63
|
-
* @param name The name of the character (e.g. "greek small letter epsilon").
|
|
64
|
-
*/
|
|
65
|
-
createTile(character, name) {
|
|
66
|
-
const tile = new ButtonView(this.locale);
|
|
67
|
-
tile.set({
|
|
68
|
-
label: character,
|
|
69
|
-
withText: true,
|
|
70
|
-
class: 'ck-character-grid__tile'
|
|
71
|
-
});
|
|
72
|
-
// Labels are vital for the users to understand what character they're looking at.
|
|
73
|
-
// For now we're using native title attribute for that, see #5817.
|
|
74
|
-
tile.extendTemplate({
|
|
75
|
-
attributes: {
|
|
76
|
-
title: name
|
|
77
|
-
},
|
|
78
|
-
on: {
|
|
79
|
-
mouseover: tile.bindTemplate.to('mouseover'),
|
|
80
|
-
focus: tile.bindTemplate.to('focus')
|
|
81
|
-
}
|
|
82
|
-
});
|
|
83
|
-
tile.on('mouseover', () => {
|
|
84
|
-
this.fire('tileHover', { name, character });
|
|
85
|
-
});
|
|
86
|
-
tile.on('focus', () => {
|
|
87
|
-
this.fire('tileFocus', { name, character });
|
|
88
|
-
});
|
|
89
|
-
tile.on('execute', () => {
|
|
90
|
-
this.fire('execute', { name, character });
|
|
91
|
-
});
|
|
92
|
-
return tile;
|
|
93
|
-
}
|
|
94
|
-
/**
|
|
95
|
-
* @inheritDoc
|
|
96
|
-
*/
|
|
97
|
-
render() {
|
|
98
|
-
super.render();
|
|
99
|
-
for (const item of this.tiles) {
|
|
100
|
-
this.focusTracker.add(item.element);
|
|
101
|
-
}
|
|
102
|
-
this.tiles.on('change', (eventInfo, { added, removed }) => {
|
|
103
|
-
if (added.length > 0) {
|
|
104
|
-
for (const item of added) {
|
|
105
|
-
this.focusTracker.add(item.element);
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
if (removed.length > 0) {
|
|
109
|
-
for (const item of removed) {
|
|
110
|
-
this.focusTracker.remove(item.element);
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
});
|
|
114
|
-
this.keystrokes.listenTo(this.element);
|
|
115
|
-
}
|
|
116
|
-
/**
|
|
117
|
-
* @inheritDoc
|
|
118
|
-
*/
|
|
119
|
-
destroy() {
|
|
120
|
-
super.destroy();
|
|
121
|
-
this.keystrokes.destroy();
|
|
122
|
-
}
|
|
123
|
-
/**
|
|
124
|
-
* Focuses the first focusable in {@link ~CharacterGridView#tiles}.
|
|
125
|
-
*/
|
|
126
|
-
focus() {
|
|
127
|
-
this.tiles.first.focus();
|
|
128
|
-
}
|
|
129
|
-
}
|
|
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/charactergridview
|
|
7
|
+
*/
|
|
8
|
+
import { View, ButtonView, addKeyboardHandlingForGrid } from 'ckeditor5/src/ui';
|
|
9
|
+
import { KeystrokeHandler, FocusTracker, global } from 'ckeditor5/src/utils';
|
|
10
|
+
import '../../theme/charactergrid.css';
|
|
11
|
+
/**
|
|
12
|
+
* A grid of character tiles. It allows browsing special characters and selecting the character to
|
|
13
|
+
* be inserted into the content.
|
|
14
|
+
*/
|
|
15
|
+
export default class CharacterGridView extends View {
|
|
16
|
+
/**
|
|
17
|
+
* Creates an instance of a character grid containing tiles representing special characters.
|
|
18
|
+
*
|
|
19
|
+
* @param locale The localization services instance.
|
|
20
|
+
*/
|
|
21
|
+
constructor(locale) {
|
|
22
|
+
super(locale);
|
|
23
|
+
this.tiles = this.createCollection();
|
|
24
|
+
this.setTemplate({
|
|
25
|
+
tag: 'div',
|
|
26
|
+
children: [
|
|
27
|
+
{
|
|
28
|
+
tag: 'div',
|
|
29
|
+
attributes: {
|
|
30
|
+
class: [
|
|
31
|
+
'ck',
|
|
32
|
+
'ck-character-grid__tiles'
|
|
33
|
+
]
|
|
34
|
+
},
|
|
35
|
+
children: this.tiles
|
|
36
|
+
}
|
|
37
|
+
],
|
|
38
|
+
attributes: {
|
|
39
|
+
class: [
|
|
40
|
+
'ck',
|
|
41
|
+
'ck-character-grid'
|
|
42
|
+
]
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
this.focusTracker = new FocusTracker();
|
|
46
|
+
this.keystrokes = new KeystrokeHandler();
|
|
47
|
+
addKeyboardHandlingForGrid({
|
|
48
|
+
keystrokeHandler: this.keystrokes,
|
|
49
|
+
focusTracker: this.focusTracker,
|
|
50
|
+
gridItems: this.tiles,
|
|
51
|
+
numberOfColumns: () => global.window
|
|
52
|
+
.getComputedStyle(this.element.firstChild) // Responsive .ck-character-grid__tiles
|
|
53
|
+
.getPropertyValue('grid-template-columns')
|
|
54
|
+
.split(' ')
|
|
55
|
+
.length,
|
|
56
|
+
uiLanguageDirection: this.locale && this.locale.uiLanguageDirection
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Creates a new tile for the grid.
|
|
61
|
+
*
|
|
62
|
+
* @param character A human-readable character displayed as the label (e.g. "ε").
|
|
63
|
+
* @param name The name of the character (e.g. "greek small letter epsilon").
|
|
64
|
+
*/
|
|
65
|
+
createTile(character, name) {
|
|
66
|
+
const tile = new ButtonView(this.locale);
|
|
67
|
+
tile.set({
|
|
68
|
+
label: character,
|
|
69
|
+
withText: true,
|
|
70
|
+
class: 'ck-character-grid__tile'
|
|
71
|
+
});
|
|
72
|
+
// Labels are vital for the users to understand what character they're looking at.
|
|
73
|
+
// For now we're using native title attribute for that, see #5817.
|
|
74
|
+
tile.extendTemplate({
|
|
75
|
+
attributes: {
|
|
76
|
+
title: name
|
|
77
|
+
},
|
|
78
|
+
on: {
|
|
79
|
+
mouseover: tile.bindTemplate.to('mouseover'),
|
|
80
|
+
focus: tile.bindTemplate.to('focus')
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
tile.on('mouseover', () => {
|
|
84
|
+
this.fire('tileHover', { name, character });
|
|
85
|
+
});
|
|
86
|
+
tile.on('focus', () => {
|
|
87
|
+
this.fire('tileFocus', { name, character });
|
|
88
|
+
});
|
|
89
|
+
tile.on('execute', () => {
|
|
90
|
+
this.fire('execute', { name, character });
|
|
91
|
+
});
|
|
92
|
+
return tile;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* @inheritDoc
|
|
96
|
+
*/
|
|
97
|
+
render() {
|
|
98
|
+
super.render();
|
|
99
|
+
for (const item of this.tiles) {
|
|
100
|
+
this.focusTracker.add(item.element);
|
|
101
|
+
}
|
|
102
|
+
this.tiles.on('change', (eventInfo, { added, removed }) => {
|
|
103
|
+
if (added.length > 0) {
|
|
104
|
+
for (const item of added) {
|
|
105
|
+
this.focusTracker.add(item.element);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
if (removed.length > 0) {
|
|
109
|
+
for (const item of removed) {
|
|
110
|
+
this.focusTracker.remove(item.element);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
this.keystrokes.listenTo(this.element);
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* @inheritDoc
|
|
118
|
+
*/
|
|
119
|
+
destroy() {
|
|
120
|
+
super.destroy();
|
|
121
|
+
this.keystrokes.destroy();
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Focuses the first focusable in {@link ~CharacterGridView#tiles}.
|
|
125
|
+
*/
|
|
126
|
+
focus() {
|
|
127
|
+
this.tiles.first.focus();
|
|
128
|
+
}
|
|
129
|
+
}
|
|
@@ -1,35 +1,35 @@
|
|
|
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/characterinfoview
|
|
7
|
-
*/
|
|
8
|
-
import type { Locale } from 'ckeditor5/src/utils';
|
|
9
|
-
import { View } from 'ckeditor5/src/ui';
|
|
10
|
-
import '../../theme/characterinfo.css';
|
|
11
|
-
/**
|
|
12
|
-
* The view displaying detailed information about a special character glyph, e.g. upon
|
|
13
|
-
* hovering it with a mouse.
|
|
14
|
-
*/
|
|
15
|
-
export default class CharacterInfoView extends View<HTMLDivElement> {
|
|
16
|
-
/**
|
|
17
|
-
* The character whose information is displayed by the view. For instance, "∑" or "¿".
|
|
18
|
-
*
|
|
19
|
-
* @observable
|
|
20
|
-
*/
|
|
21
|
-
character: string | null;
|
|
22
|
-
/**
|
|
23
|
-
* The name of the {@link #character}. For instance, "N-ary summation" or "Inverted question mark".
|
|
24
|
-
*
|
|
25
|
-
* @observable
|
|
26
|
-
*/
|
|
27
|
-
name: string | null;
|
|
28
|
-
/**
|
|
29
|
-
* The "Unicode string" of the {@link #character}. For instance "U+0061".
|
|
30
|
-
*
|
|
31
|
-
* @observable
|
|
32
|
-
*/
|
|
33
|
-
readonly code: string;
|
|
34
|
-
constructor(locale: Locale);
|
|
35
|
-
}
|
|
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/characterinfoview
|
|
7
|
+
*/
|
|
8
|
+
import type { Locale } from 'ckeditor5/src/utils';
|
|
9
|
+
import { View } from 'ckeditor5/src/ui';
|
|
10
|
+
import '../../theme/characterinfo.css';
|
|
11
|
+
/**
|
|
12
|
+
* The view displaying detailed information about a special character glyph, e.g. upon
|
|
13
|
+
* hovering it with a mouse.
|
|
14
|
+
*/
|
|
15
|
+
export default class CharacterInfoView extends View<HTMLDivElement> {
|
|
16
|
+
/**
|
|
17
|
+
* The character whose information is displayed by the view. For instance, "∑" or "¿".
|
|
18
|
+
*
|
|
19
|
+
* @observable
|
|
20
|
+
*/
|
|
21
|
+
character: string | null;
|
|
22
|
+
/**
|
|
23
|
+
* The name of the {@link #character}. For instance, "N-ary summation" or "Inverted question mark".
|
|
24
|
+
*
|
|
25
|
+
* @observable
|
|
26
|
+
*/
|
|
27
|
+
name: string | null;
|
|
28
|
+
/**
|
|
29
|
+
* The "Unicode string" of the {@link #character}. For instance "U+0061".
|
|
30
|
+
*
|
|
31
|
+
* @observable
|
|
32
|
+
*/
|
|
33
|
+
readonly code: string;
|
|
34
|
+
constructor(locale: Locale);
|
|
35
|
+
}
|