Skip to content

Commit

Permalink
Emoji
Browse files Browse the repository at this point in the history
  • Loading branch information
ledyba committed Dec 8, 2024
1 parent acf97b7 commit 4182819
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 7 deletions.
2 changes: 2 additions & 0 deletions client/src/constant.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// https://github.com/twitter/twemoji/issues/580
export const EMOJI_URL_BASE = 'https://cdnjs.cloudflare.com/ajax/libs/twemoji/14.0.2/';
4 changes: 2 additions & 2 deletions client/src/omote/layers/Index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { mat4 } from 'gl-matrix';
import Page from './Page';
import twemoji from 'twemoji';
import * as protocol from '../../protocol';
import { EMOJI_URL_BASE } from '../../constant';

export default class Index extends Layer {
private readonly wheelEventListener_: (ev: WheelEvent) => void;
Expand Down Expand Up @@ -69,8 +70,7 @@ export default class Index extends Layer {
tooltip.classList.remove('hidden');

// title
this.tooltipTitle_.textContent = m.title;
twemoji.parse(this.tooltipTitle_);
this.tooltipTitle_.innerHTML = twemoji.parse(m.title, { base: EMOJI_URL_BASE });
this.tooltipDate_.innerHTML = m.date;
this.fixTooltipPosition_();
}
Expand Down
6 changes: 3 additions & 3 deletions client/src/omote/layers/Page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import World from '../World'
import Layer from '../Layer';
import { mat4 } from 'gl-matrix';
import twemoji from 'twemoji';
import { EMOJI_URL_BASE } from '../../constant';

export default class Page extends Layer {

Expand Down Expand Up @@ -40,8 +41,7 @@ export default class Page extends Layer {
}

onLoad_(body: string) {
this.content_.innerHTML = body;
twemoji.parse(this.content_);
this.content_.innerHTML = twemoji.parse(body, { base: EMOJI_URL_BASE });

const contents = this.content_.getElementsByTagName('script');
for(let i = 0; i < contents.length; ++i) {
Expand Down Expand Up @@ -108,4 +108,4 @@ const backButtonSrc = `
x1="1em" y1="4em" x2="4em" y2="1em"
stroke="rgba(0, 0, 0, 0.5)" stroke-width="1em"/>
</svg>
`;
`;
8 changes: 6 additions & 2 deletions client/src/ura/editor/Preview.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import twemoji from 'twemoji';
import Editor from './Editor';
import { EMOJI_URL_BASE } from '../../constant';

export default class Preview {
private readonly container_: HTMLDivElement;
Expand All @@ -12,6 +14,8 @@ export default class Preview {
this.editor_ = editor;
}
onChange(body: string) {
this.container_.innerHTML = body;
this.container_.innerHTML = twemoji.parse(body, {
base: EMOJI_URL_BASE,
});
}
}
}

0 comments on commit 4182819

Please sign in to comment.