mirror of
https://github.com/GitJournal/GitJournal.git
synced 2025-06-30 19:36:25 +08:00
Add scaffolding to make emoji parsing optional
This commit is contained in:
17
lib/core/processors/emoji_processor.dart
Normal file
17
lib/core/processors/emoji_processor.dart
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
import 'package:flutter_emoji/flutter_emoji.dart';
|
||||||
|
|
||||||
|
import 'package:gitjournal/core/note.dart';
|
||||||
|
|
||||||
|
class EmojiProcessor {
|
||||||
|
static final _emojiParser = EmojiParser();
|
||||||
|
|
||||||
|
void onSave(Note note) {
|
||||||
|
note.title = _emojiParser.emojify(note.title);
|
||||||
|
note.body = _emojiParser.emojify(note.body);
|
||||||
|
}
|
||||||
|
|
||||||
|
void onLoad(Note note) {
|
||||||
|
note.body = _emojiParser.unemojify(note.body);
|
||||||
|
note.title = _emojiParser.unemojify(note.title);
|
||||||
|
}
|
||||||
|
}
|
@ -6,7 +6,9 @@ class WikiLinksAutoAddProcessor {
|
|||||||
|
|
||||||
WikiLinksAutoAddProcessor(this.rootFolder);
|
WikiLinksAutoAddProcessor(this.rootFolder);
|
||||||
|
|
||||||
void process(Note note) {}
|
void onSave(Note note) {
|
||||||
|
//note.body = processBody(note.body, tags);
|
||||||
|
}
|
||||||
|
|
||||||
String processBody(String body, List<String> tags) {
|
String processBody(String body, List<String> tags) {
|
||||||
for (var tag in tags) {
|
for (var tag in tags) {
|
||||||
|
@ -69,6 +69,7 @@ class Settings extends ChangeNotifier {
|
|||||||
bool saveTitleInH1 = true;
|
bool saveTitleInH1 = true;
|
||||||
|
|
||||||
bool swipeToDelete = true;
|
bool swipeToDelete = true;
|
||||||
|
bool emojiParser = true;
|
||||||
|
|
||||||
Set<String> inlineTagPrefixes = {'#'};
|
Set<String> inlineTagPrefixes = {'#'};
|
||||||
|
|
||||||
@ -124,6 +125,7 @@ class Settings extends ChangeNotifier {
|
|||||||
|
|
||||||
version = pref.getInt("settingsVersion") ?? version;
|
version = pref.getInt("settingsVersion") ?? version;
|
||||||
proMode = pref.getBool("proMode") ?? proMode;
|
proMode = pref.getBool("proMode") ?? proMode;
|
||||||
|
emojiParser = pref.getBool("emojiParser") ?? emojiParser;
|
||||||
proExpirationDate =
|
proExpirationDate =
|
||||||
pref.getString("proExpirationDate") ?? proExpirationDate;
|
pref.getString("proExpirationDate") ?? proExpirationDate;
|
||||||
|
|
||||||
@ -218,6 +220,7 @@ class Settings extends ChangeNotifier {
|
|||||||
_setString(pref, "proExpirationDate", proExpirationDate,
|
_setString(pref, "proExpirationDate", proExpirationDate,
|
||||||
defaultSet.proExpirationDate);
|
defaultSet.proExpirationDate);
|
||||||
_setBool(pref, "proMode", proMode, defaultSet.proMode);
|
_setBool(pref, "proMode", proMode, defaultSet.proMode);
|
||||||
|
_setBool(pref, "emojiParser", emojiParser, defaultSet.emojiParser);
|
||||||
_setString(pref, "homeScreen", homeScreen.toInternalString(),
|
_setString(pref, "homeScreen", homeScreen.toInternalString(),
|
||||||
defaultSet.homeScreen.toInternalString());
|
defaultSet.homeScreen.toInternalString());
|
||||||
_setString(pref, "imageLocationSpec", imageLocationSpec,
|
_setString(pref, "imageLocationSpec", imageLocationSpec,
|
||||||
@ -319,6 +322,7 @@ class Settings extends ChangeNotifier {
|
|||||||
'saveTitleInH1': saveTitleInH1.toString(),
|
'saveTitleInH1': saveTitleInH1.toString(),
|
||||||
'swipeToDelete': swipeToDelete.toString(),
|
'swipeToDelete': swipeToDelete.toString(),
|
||||||
'inlineTagPrefixes': inlineTagPrefixes.join(' '),
|
'inlineTagPrefixes': inlineTagPrefixes.join(' '),
|
||||||
|
'emojiParser': emojiParser.toString(),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user