mirror of
https://github.com/GitJournal/GitJournal.git
synced 2025-06-26 00:29:20 +08:00
Minor refactoring
This commit is contained in:
@ -116,7 +116,8 @@ class Note with NotesNotifier {
|
|||||||
static final _linksLoader = LinksLoader();
|
static final _linksLoader = LinksLoader();
|
||||||
|
|
||||||
Note(this.parent, this._filePath) {
|
Note(this.parent, this._filePath) {
|
||||||
noteSerializer = NoteSerializer.fromConfig(parent.config);
|
var settings = NoteSerializationSettings.fromConfig(parent.config);
|
||||||
|
noteSerializer = NoteSerializer.fromConfig(settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
Note.newNote(
|
Note.newNote(
|
||||||
@ -127,7 +128,8 @@ class Note with NotesNotifier {
|
|||||||
created = DateTime.now();
|
created = DateTime.now();
|
||||||
_loadState = NoteLoadState.Loaded;
|
_loadState = NoteLoadState.Loaded;
|
||||||
_fileFormat = NoteFileFormat.Markdown;
|
_fileFormat = NoteFileFormat.Markdown;
|
||||||
noteSerializer = NoteSerializer.fromConfig(parent.config);
|
var settings = NoteSerializationSettings.fromConfig(parent.config);
|
||||||
|
noteSerializer = NoteSerializer.fromConfig(settings);
|
||||||
|
|
||||||
if (extraProps.isNotEmpty) {
|
if (extraProps.isNotEmpty) {
|
||||||
extraProps.forEach((key, value) {
|
extraProps.forEach((key, value) {
|
||||||
|
@ -44,18 +44,20 @@ class NoteSerializationSettings {
|
|||||||
bool tagsHaveHash = false;
|
bool tagsHaveHash = false;
|
||||||
|
|
||||||
SettingsTitle titleSettings = SettingsTitle.Default;
|
SettingsTitle titleSettings = SettingsTitle.Default;
|
||||||
|
|
||||||
|
NoteSerializationSettings.fromConfig(NotesFolderConfig config) {
|
||||||
|
modifiedKey = config.yamlModifiedKey;
|
||||||
|
createdKey = config.yamlCreatedKey;
|
||||||
|
tagsKey = config.yamlTagsKey;
|
||||||
|
titleSettings = config.titleSettings;
|
||||||
|
}
|
||||||
|
NoteSerializationSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
class NoteSerializer implements NoteSerializerInterface {
|
class NoteSerializer implements NoteSerializerInterface {
|
||||||
var settings = NoteSerializationSettings();
|
var settings = NoteSerializationSettings();
|
||||||
|
|
||||||
NoteSerializer.fromConfig(NotesFolderConfig config) {
|
NoteSerializer.fromConfig(this.settings);
|
||||||
settings.modifiedKey = config.yamlModifiedKey;
|
|
||||||
settings.createdKey = config.yamlCreatedKey;
|
|
||||||
settings.tagsKey = config.yamlTagsKey;
|
|
||||||
settings.titleSettings = config.titleSettings;
|
|
||||||
}
|
|
||||||
|
|
||||||
NoteSerializer.raw();
|
NoteSerializer.raw();
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
@ -211,8 +211,9 @@ class NoteOutputExample extends StatelessWidget {
|
|||||||
var settings = Provider.of<Settings>(context);
|
var settings = Provider.of<Settings>(context);
|
||||||
|
|
||||||
var doc = MdYamlDoc();
|
var doc = MdYamlDoc();
|
||||||
NoteSerializer.fromConfig(NotesFolderConfig.fromSettings(null, settings))
|
var folderConfig = NotesFolderConfig.fromSettings(null, settings);
|
||||||
.encode(note, doc);
|
var serialSettings = NoteSerializationSettings.fromConfig(folderConfig);
|
||||||
|
NoteSerializer.fromConfig(serialSettings).encode(note, doc);
|
||||||
|
|
||||||
var codec = MarkdownYAMLCodec();
|
var codec = MarkdownYAMLCodec();
|
||||||
var noteStr = codec.encode(doc);
|
var noteStr = codec.encode(doc);
|
||||||
|
Reference in New Issue
Block a user