mirror of
https://github.com/BoostIo/Boostnote
synced 2025-12-13 09:46:22 +00:00
Change to use the module
This commit is contained in:
@@ -4,6 +4,7 @@ import styles from './MarkdownEditor.styl'
|
|||||||
import CodeEditor from 'browser/components/CodeEditor'
|
import CodeEditor from 'browser/components/CodeEditor'
|
||||||
import MarkdownPreview from 'browser/components/MarkdownPreview'
|
import MarkdownPreview from 'browser/components/MarkdownPreview'
|
||||||
import eventEmitter from 'browser/main/lib/eventEmitter'
|
import eventEmitter from 'browser/main/lib/eventEmitter'
|
||||||
|
import { findStorage } from 'browser/lib/findStorage'
|
||||||
const _ = require('lodash')
|
const _ = require('lodash')
|
||||||
|
|
||||||
class MarkdownEditor extends React.Component {
|
class MarkdownEditor extends React.Component {
|
||||||
@@ -214,10 +215,7 @@ class MarkdownEditor extends React.Component {
|
|||||||
let previewStyle = {}
|
let previewStyle = {}
|
||||||
if (this.props.ignorePreviewPointerEvents) previewStyle.pointerEvents = 'none'
|
if (this.props.ignorePreviewPointerEvents) previewStyle.pointerEvents = 'none'
|
||||||
|
|
||||||
const cachedStorageList = JSON.parse(localStorage.getItem('storages'))
|
const storage = findStorage(storageKey)
|
||||||
if (!_.isArray(cachedStorageList)) throw new Error('Target storage doesn\'t exist.')
|
|
||||||
const storage = _.find(cachedStorageList, {key: storageKey})
|
|
||||||
if (storage === undefined) throw new Error('Target storage doesn\'t exist.')
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={className == null
|
<div className={className == null
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import MarkdownPreview from 'browser/components/MarkdownPreview'
|
|||||||
import MarkdownEditor from 'browser/components/MarkdownEditor'
|
import MarkdownEditor from 'browser/components/MarkdownEditor'
|
||||||
import CodeEditor from 'browser/components/CodeEditor'
|
import CodeEditor from 'browser/components/CodeEditor'
|
||||||
import CodeMirror from 'codemirror'
|
import CodeMirror from 'codemirror'
|
||||||
|
import { findStorage } from 'browser/lib/findStorage'
|
||||||
|
|
||||||
const electron = require('electron')
|
const electron = require('electron')
|
||||||
const { clipboard } = electron
|
const { clipboard } = electron
|
||||||
@@ -106,10 +107,7 @@ class NoteDetail extends React.Component {
|
|||||||
let editorIndentSize = parseInt(config.editor.indentSize, 10)
|
let editorIndentSize = parseInt(config.editor.indentSize, 10)
|
||||||
if (!(editorFontSize > 0 && editorFontSize < 132)) editorIndentSize = 4
|
if (!(editorFontSize > 0 && editorFontSize < 132)) editorIndentSize = 4
|
||||||
|
|
||||||
const cachedStorageList = JSON.parse(localStorage.getItem('storages'))
|
const storage = findStorage(note.storage)
|
||||||
if (!_.isArray(cachedStorageList)) throw new Error('Target storage doesn\'t exist.')
|
|
||||||
const storage = _.find(cachedStorageList, {key: note.storage})
|
|
||||||
if (storage === undefined) throw new Error('Target storage doesn\'t exist.')
|
|
||||||
|
|
||||||
if (note.type === 'SNIPPET_NOTE') {
|
if (note.type === 'SNIPPET_NOTE') {
|
||||||
let tabList = note.snippets.map((snippet, index) => {
|
let tabList = note.snippets.map((snippet, index) => {
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ const fs = require('fs')
|
|||||||
const path = require('path')
|
const path = require('path')
|
||||||
const _ = require('lodash')
|
const _ = require('lodash')
|
||||||
const sander = require('sander')
|
const sander = require('sander')
|
||||||
|
const { findStorage } = require('browser/lib/findStorage')
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @description To copy an image and return the path.
|
* @description To copy an image and return the path.
|
||||||
@@ -12,11 +13,7 @@ const sander = require('sander')
|
|||||||
function copyImage (filePath, storageKey) {
|
function copyImage (filePath, storageKey) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
try {
|
try {
|
||||||
const cachedStorageList = JSON.parse(localStorage.getItem('storages'))
|
const targetStorage = findStorage(storageKey)
|
||||||
if (!_.isArray(cachedStorageList)) throw new Error('Target storage doesn\'t exist.')
|
|
||||||
const storage = _.find(cachedStorageList, {key: storageKey})
|
|
||||||
if (storage === undefined) throw new Error('Target storage doesn\'t exist.')
|
|
||||||
const targetStorage = storage
|
|
||||||
|
|
||||||
const inputImage = fs.createReadStream(filePath)
|
const inputImage = fs.createReadStream(filePath)
|
||||||
const imageExt = path.extname(filePath)
|
const imageExt = path.extname(filePath)
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ const keygen = require('browser/lib/keygen')
|
|||||||
const path = require('path')
|
const path = require('path')
|
||||||
const resolveStorageData = require('./resolveStorageData')
|
const resolveStorageData = require('./resolveStorageData')
|
||||||
const CSON = require('@rokt33r/season')
|
const CSON = require('@rokt33r/season')
|
||||||
|
const { findStorage } = require('browser/lib/findStorage')
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {String} storageKey
|
* @param {String} storageKey
|
||||||
@@ -29,11 +30,7 @@ function createFolder (storageKey, input) {
|
|||||||
if (!_.isString(input.name)) throw new Error('Name must be a string.')
|
if (!_.isString(input.name)) throw new Error('Name must be a string.')
|
||||||
if (!_.isString(input.color)) throw new Error('Color must be a string.')
|
if (!_.isString(input.color)) throw new Error('Color must be a string.')
|
||||||
|
|
||||||
rawStorages = JSON.parse(localStorage.getItem('storages'))
|
targetStorage = findStorage(storageKey)
|
||||||
if (!_.isArray(rawStorages)) throw new Error('Target storage doesn\'t exist.')
|
|
||||||
|
|
||||||
targetStorage = _.find(rawStorages, {key: storageKey})
|
|
||||||
if (targetStorage == null) throw new Error('Target storage doesn\'t exist.')
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
return Promise.reject(e)
|
return Promise.reject(e)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ const _ = require('lodash')
|
|||||||
const keygen = require('browser/lib/keygen')
|
const keygen = require('browser/lib/keygen')
|
||||||
const path = require('path')
|
const path = require('path')
|
||||||
const CSON = require('@rokt33r/season')
|
const CSON = require('@rokt33r/season')
|
||||||
|
const { findStorage } = require('browser/lib/findStorage')
|
||||||
|
|
||||||
function validateInput (input) {
|
function validateInput (input) {
|
||||||
if (!_.isArray(input.tags)) input.tags = []
|
if (!_.isArray(input.tags)) input.tags = []
|
||||||
@@ -38,11 +39,7 @@ function createNote (storageKey, input) {
|
|||||||
input = Object.assign({}, input)
|
input = Object.assign({}, input)
|
||||||
validateInput(input)
|
validateInput(input)
|
||||||
|
|
||||||
let cachedStorageList = JSON.parse(localStorage.getItem('storages'))
|
targetStorage = findStorage(storageKey)
|
||||||
if (!_.isArray(cachedStorageList)) throw new Error('Target storage doesn\'t exist.')
|
|
||||||
|
|
||||||
targetStorage = _.find(cachedStorageList, {key: storageKey})
|
|
||||||
if (targetStorage == null) throw new Error('Target storage doesn\'t exist.')
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
return Promise.reject(e)
|
return Promise.reject(e)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ const resolveStorageData = require('./resolveStorageData')
|
|||||||
const resolveStorageNotes = require('./resolveStorageNotes')
|
const resolveStorageNotes = require('./resolveStorageNotes')
|
||||||
const CSON = require('@rokt33r/season')
|
const CSON = require('@rokt33r/season')
|
||||||
const sander = require('sander')
|
const sander = require('sander')
|
||||||
|
const { findStorage } = require('browser/lib/findStorage')
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {String} storageKey
|
* @param {String} storageKey
|
||||||
@@ -21,11 +22,7 @@ function deleteFolder (storageKey, folderKey) {
|
|||||||
let rawStorages
|
let rawStorages
|
||||||
let targetStorage
|
let targetStorage
|
||||||
try {
|
try {
|
||||||
rawStorages = JSON.parse(localStorage.getItem('storages'))
|
targetStorage = findStorage(storageKey)
|
||||||
if (!_.isArray(rawStorages)) throw new Error('Target storage doesn\'t exist.')
|
|
||||||
|
|
||||||
targetStorage = _.find(rawStorages, {key: storageKey})
|
|
||||||
if (targetStorage == null) throw new Error('Target storage doesn\'t exist.')
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
return Promise.reject(e)
|
return Promise.reject(e)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,15 +2,12 @@ const resolveStorageData = require('./resolveStorageData')
|
|||||||
const _ = require('lodash')
|
const _ = require('lodash')
|
||||||
const path = require('path')
|
const path = require('path')
|
||||||
const sander = require('sander')
|
const sander = require('sander')
|
||||||
|
const { findStorage } = require('browser/lib/findStorage')
|
||||||
|
|
||||||
function deleteNote (storageKey, noteKey) {
|
function deleteNote (storageKey, noteKey) {
|
||||||
let targetStorage
|
let targetStorage
|
||||||
try {
|
try {
|
||||||
let cachedStorageList = JSON.parse(localStorage.getItem('storages'))
|
targetStorage = findStorage(storageKey)
|
||||||
if (!_.isArray(cachedStorageList)) throw new Error('Target storage doesn\'t exist.')
|
|
||||||
|
|
||||||
targetStorage = _.find(cachedStorageList, {key: storageKey})
|
|
||||||
if (targetStorage == null) throw new Error('Target storage doesn\'t exist.')
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
return Promise.reject(e)
|
return Promise.reject(e)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,17 +4,13 @@ const path = require('path')
|
|||||||
const CSON = require('@rokt33r/season')
|
const CSON = require('@rokt33r/season')
|
||||||
const keygen = require('browser/lib/keygen')
|
const keygen = require('browser/lib/keygen')
|
||||||
const sander = require('sander')
|
const sander = require('sander')
|
||||||
|
const { findStorage } = require('browser/lib/findStorage')
|
||||||
|
|
||||||
function moveNote (storageKey, noteKey, newStorageKey, newFolderKey) {
|
function moveNote (storageKey, noteKey, newStorageKey, newFolderKey) {
|
||||||
let oldStorage, newStorage
|
let oldStorage, newStorage
|
||||||
try {
|
try {
|
||||||
let cachedStorageList = JSON.parse(localStorage.getItem('storages'))
|
oldStorage = findStorage(storageKey)
|
||||||
if (!_.isArray(cachedStorageList)) throw new Error('Storage doesn\'t exist.')
|
newStorage = findStorage(newStorageKey)
|
||||||
|
|
||||||
oldStorage = _.find(cachedStorageList, {key: storageKey})
|
|
||||||
if (oldStorage == null) throw new Error('Storage doesn\'t exist.')
|
|
||||||
|
|
||||||
newStorage = _.find(cachedStorageList, {key: newStorageKey})
|
|
||||||
if (newStorage == null) throw new Error('Target storage doesn\'t exist.')
|
if (newStorage == null) throw new Error('Target storage doesn\'t exist.')
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
return Promise.reject(e)
|
return Promise.reject(e)
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
const _ = require('lodash')
|
const _ = require('lodash')
|
||||||
const resolveStorageData = require('./resolveStorageData')
|
const resolveStorageData = require('./resolveStorageData')
|
||||||
|
const { findStorage } = require('browser/lib/findStorage')
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {String} key
|
* @param {String} key
|
||||||
* @param {String} name
|
* @param {String} name
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ const resolveStorageData = require('./resolveStorageData')
|
|||||||
const _ = require('lodash')
|
const _ = require('lodash')
|
||||||
const path = require('path')
|
const path = require('path')
|
||||||
const CSON = require('@rokt33r/season')
|
const CSON = require('@rokt33r/season')
|
||||||
|
const { findStorage } = require('browser/lib/findStorage')
|
||||||
|
|
||||||
function validateInput (input) {
|
function validateInput (input) {
|
||||||
let validatedInput = {}
|
let validatedInput = {}
|
||||||
@@ -68,11 +69,7 @@ function updateNote (storageKey, noteKey, input) {
|
|||||||
if (input == null) throw new Error('No input found.')
|
if (input == null) throw new Error('No input found.')
|
||||||
input = validateInput(input)
|
input = validateInput(input)
|
||||||
|
|
||||||
let cachedStorageList = JSON.parse(localStorage.getItem('storages'))
|
targetStorage = findStorage(storageKey)
|
||||||
if (!_.isArray(cachedStorageList)) throw new Error('Target storage doesn\'t exist.')
|
|
||||||
|
|
||||||
targetStorage = _.find(cachedStorageList, {key: storageKey})
|
|
||||||
if (targetStorage == null) throw new Error('Target storage doesn\'t exist.')
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
return Promise.reject(e)
|
return Promise.reject(e)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user