Use TextFormatter Emoji plugin

This commit is contained in:
Sajjad Hasehmian 2016-02-01 00:31:54 +03:30
parent df125862bb
commit e9ea22d591
5 changed files with 20 additions and 648 deletions

View File

@ -3,8 +3,5 @@ var gulp = require('flarum-gulp');
gulp({
modules: {
'flarum/emoji': 'src/**/*.js'
},
files: [
'bower_components/twemoji/index.js'
]
}
});

View File

@ -1,6 +0,0 @@
{
"name": "flarum-emoji",
"devDependencies": {
"twemoji": "https://raw.githubusercontent.com/twitter/twemoji/gh-pages/twemoji.js"
}
}

File diff suppressed because one or more lines are too long

View File

@ -4,21 +4,4 @@ import { override } from 'flarum/extend';
import app from 'flarum/app';
import Post from 'flarum/models/Post';
app.initializers.add('flarum-emoji', () => {
override(Post.prototype, 'contentHtml', function(original) {
const contentHtml = original();
if (this.oldContentHtml !== contentHtml) {
this.emojifiedContentHtml = twemoji.parse(contentHtml);
this.oldContentHtml = contentHtml;
}
return this.emojifiedContentHtml;
});
override(s9e.TextFormatter, 'preview', (original, text, element) => {
original(text, element);
twemoji.parse(element);
});
});
app.initializers.add('flarum-emoji', () => {});

View File

@ -1,4 +1,4 @@
<?php
<?php
/*
* This file is part of Flarum.
*
@ -28,17 +28,21 @@ class FormatEmoticons
*/
public function addEmoticons(ConfigureFormatter $event)
{
$event->configurator->Emoticons->add(':)', '&#x1f604;');
$event->configurator->Emoticons->add(':D', '&#x1f603;');
$event->configurator->Emoticons->add(':P', '&#x1f61c;');
$event->configurator->Emoticons->add(':(', '&#x1f61f;');
$event->configurator->Emoticons->add(':|', '&#x1f610;');
$event->configurator->Emoticons->add(';)', '&#x1f609;');
$event->configurator->Emoticons->add(':*', '&#x1f618;');
$event->configurator->Emoticons->add(':\'(', '&#x1f622;');
$event->configurator->Emoticons->add(':\')', '&#x1f602;');
$event->configurator->Emoticons->add(':O', '&#x1f62e;');
$event->configurator->Emoticons->add('B)', '&#x1f60e;');
$event->configurator->Emoticons->add('>:(', '&#x1f621;');
$event->configurator->Emoji->useTwemoji();
$event->configurator->Emoji->setImageSize(32);
$event->configurator->Emoji->omitImageSize();
$event->configurator->Emoji->addAlias(':)', '😄');
$event->configurator->Emoji->addAlias(':D', '😃');
$event->configurator->Emoji->addAlias(':P', '😜');
$event->configurator->Emoji->addAlias(':(', '😟');
$event->configurator->Emoji->addAlias(':|', '😐');
$event->configurator->Emoji->addAlias(';)', '😉');
$event->configurator->Emoji->addAlias(':*', '😘');
$event->configurator->Emoji->addAlias(':\'(', '😢');
$event->configurator->Emoji->addAlias(':\')', '😂');
$event->configurator->Emoji->addAlias(':O', '😮');
$event->configurator->Emoji->addAlias('B)', '😎');
$event->configurator->Emoji->addAlias('>:(', '😡');
}
}