Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removed unicode characters from the bottom of emoji picker. #17689

Merged
merged 1 commit into from
Dec 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 0 additions & 38 deletions packages/ckeditor5-emoji/src/ui/emojiinfoview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,6 @@ export default class EmojiInfoView extends View<HTMLDivElement> {
*/
declare public name: string | null;

/**
* The "Unicode string" of the {@link #emoji}. For instance "U+0061".
*
* @observable
*/
declare public readonly code: string;

/**
* @inheritDoc
*/
Expand All @@ -47,7 +40,6 @@ export default class EmojiInfoView extends View<HTMLDivElement> {

this.set( 'emoji', null );
this.set( 'name', null );
this.bind( 'code' ).to( this, 'emoji', characterToUnicodeString );

this.setTemplate( {
tag: 'div',
Expand All @@ -65,19 +57,6 @@ export default class EmojiInfoView extends View<HTMLDivElement> {
text: bind.to( 'name', name => name ? name : '\u200B' )
}
]
},
{
tag: 'span',
attributes: {
class: [
'ck-emoji-info__code'
]
},
children: [
{
text: bind.to( 'code' )
}
]
}
],
attributes: {
Expand All @@ -89,20 +68,3 @@ export default class EmojiInfoView extends View<HTMLDivElement> {
} );
}
}

/**
* Converts a character into a "Unicode string", for instance:
*
* "$" -> "U+0024"
*
* Returns an empty string when the character is `null`.
*/
function characterToUnicodeString( emoji: string | null ): string {
if ( emoji === null ) {
return '';
}

const hexCode = emoji.codePointAt( 0 )!.toString( 16 );

return 'U+' + ( '0000' + hexCode ).slice( -4 );
}
18 changes: 1 addition & 17 deletions packages/ckeditor5-emoji/tests/ui/emojiinfoview.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,41 +33,25 @@ describe( 'EmojiInfoView', () => {
} );
} );

describe( '#code', () => {
it( 'is defined', () => {
expect( view.code ).to.equal( '' );
} );

it( 'is bound to #emoji', () => {
view.set( 'emoji', 'A' );

expect( view.code ).to.equal( 'U+0041' );
} );
} );

describe( '#element', () => {
it( 'is being created from template', () => {
expect( view.element.classList.contains( 'ck' ) ).to.be.true;
expect( view.element.classList.contains( 'ck-emoji-info' ) ).to.be.true;

expect( view.element.firstElementChild.classList.contains( 'ck-emoji-info__name' ) ).to.be.true;
expect( view.element.lastElementChild.classList.contains( 'ck-emoji-info__code' ) ).to.be.true;
} );

it( 'is being updated when #code and #name have changed', () => {
it( 'is being updated when #name have changed', () => {
const infoEl = view.element.firstElementChild;
const codeEl = view.element.lastElementChild;

expect( infoEl.innerText ).to.equal( '\u200B' );
expect( codeEl.innerText ).to.equal( '' );

view.set( {
emoji: 'A',
name: 'SYMBOL: A'
} );

expect( infoEl.innerText ).to.equal( 'SYMBOL: A' );
expect( codeEl.innerText ).to.equal( 'U+0041' );
} );
} );
} );
Expand Down