From a95b7fc4b608e3772563c9c48e986ee29839be7e Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Sat, 9 Jun 2018 17:17:40 -0700 Subject: [PATCH] Emoji work --- app/components/Layout/Layout.js | 12 ---------- app/components/PageTitle/PageTitle.js | 9 +++++++- app/scenes/Document/Document.js | 33 ++++++++++++++++++++++++++- 3 files changed, 40 insertions(+), 14 deletions(-) diff --git a/app/components/Layout/Layout.js b/app/components/Layout/Layout.js index 99b7a4ed5..7ba9a146a 100644 --- a/app/components/Layout/Layout.js +++ b/app/components/Layout/Layout.js @@ -81,18 +81,6 @@ class Layout extends React.Component { name="viewport" content="width=device-width, initial-scale=1.0" /> - - diff --git a/app/components/PageTitle/PageTitle.js b/app/components/PageTitle/PageTitle.js index 56105504b..8a6999c9f 100644 --- a/app/components/PageTitle/PageTitle.js +++ b/app/components/PageTitle/PageTitle.js @@ -4,11 +4,18 @@ import { Helmet } from 'react-helmet'; type Props = { title: string, + favicon?: string, }; -const PageTitle = ({ title }: Props) => ( +const PageTitle = ({ title, favicon }: Props) => ( {`${title} - Outline`} + ); diff --git a/app/scenes/Document/Document.js b/app/scenes/Document/Document.js index 960c8d08c..c5edb5b63 100644 --- a/app/scenes/Document/Document.js +++ b/app/scenes/Document/Document.js @@ -51,6 +51,25 @@ type Props = { ui: UiStore, }; +function toCodePoint(unicodeSurrogates, sep) { + var r = [], + c = 0, + p = 0, + i = 0; + while (i < unicodeSurrogates.length) { + c = unicodeSurrogates.charCodeAt(i++); + if (p) { + r.push((0x10000 + ((p - 0xd800) << 10) + (c - 0xdc00)).toString(16)); + p = 0; + } else if (0xd800 <= c && c <= 0xdbff) { + p = c; + } else { + r.push(c.toString(16)); + } + } + return r.join(sep || '-'); +} + @observer class DocumentScene extends React.Component { savedTimeout: TimeoutID; @@ -257,10 +276,22 @@ class DocumentScene extends React.Component { ); } + let favicon; + if (document && document.emoji) { + favicon = `https://twemoji.maxcdn.com/2/72x72/${toCodePoint( + document.emoji + )}.png`; + } + return ( {isMoving && document && } - {titleText && } + {titleText && ( + + )} {(this.isLoading || this.isSaving) && } {!document || !Editor ? (