1
0
mirror of https://github.com/BoostIo/Boostnote synced 2025-12-13 17:56:25 +00:00

snippet note

This commit is contained in:
Dick Choi
2016-07-21 01:17:53 +09:00
parent 69d11b5cd0
commit b6d34472fe
13 changed files with 890 additions and 96 deletions

View File

@@ -322,18 +322,49 @@ function removeFolder (storageKey, folderKey) {
.then((storage) => storage.toJSON())
}
function createNote (storageKey, folderKey, input) {
function createMarkdownNote (storageKey, folderKey, input) {
let key = keygen()
while (notes.some((note) => note.storage === storageKey && note.folder === folderKey && note.key === key)) {
key = keygen()
}
let newNote = new Note(Object.assign({
type: 'MARKDOWN_NOTE',
tags: [],
title: '',
content: ''
}, input, {
type: 'MARKDOWN_NOTE',
storage: storageKey,
folder: folderKey,
key: key,
isStarred: false,
createdAt: new Date(),
updatedAt: new Date()
}))
notes.push(newNote)
return newNote
.save()
.then(() => newNote.toJSON())
}
function createSnippetNote (storageKey, folderKey, input) {
let key = keygen()
while (notes.some((note) => note.storage === storageKey && note.folder === folderKey && note.key === key)) {
key = keygen()
}
let newNote = new Note(Object.assign({
tags: [],
title: '',
description: '',
snippets: [{
name: '',
mode: 'text',
content: ''
}]
}, input, {
type: 'SNIPPET_NOTE',
storage: storageKey,
folder: folderKey,
key: key,
@@ -374,7 +405,8 @@ export default {
createFolder,
updateFolder,
removeFolder,
createNote,
createMarkdownNote,
createSnippetNote,
updateNote,
removeNote
}