mirror of
https://github.com/laurent22/joplin.git
synced 2024-12-24 10:27:10 +02:00
Apply linter config
This commit is contained in:
parent
d355169b60
commit
a8ae0f8078
@ -10,8 +10,8 @@ async function handleAutocompletionPromise(line) {
|
|||||||
// Auto-complete the command name
|
// Auto-complete the command name
|
||||||
const names = await app().commandNames();
|
const names = await app().commandNames();
|
||||||
let words = getArguments(line);
|
let words = getArguments(line);
|
||||||
//If there is only one word and it is not already a command name then you
|
// If there is only one word and it is not already a command name then you
|
||||||
//should look for commmands it could be
|
// should look for commmands it could be
|
||||||
if (words.length == 1) {
|
if (words.length == 1) {
|
||||||
if (names.indexOf(words[0]) === -1) {
|
if (names.indexOf(words[0]) === -1) {
|
||||||
let x = names.filter(n => n.indexOf(words[0]) === 0);
|
let x = names.filter(n => n.indexOf(words[0]) === 0);
|
||||||
@ -23,29 +23,29 @@ async function handleAutocompletionPromise(line) {
|
|||||||
return line;
|
return line;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//There is more than one word and it is a command
|
// There is more than one word and it is a command
|
||||||
const metadata = (await app().commandMetadata())[words[0]];
|
const metadata = (await app().commandMetadata())[words[0]];
|
||||||
//If for some reason this command does not have any associated metadata
|
// If for some reason this command does not have any associated metadata
|
||||||
//just don't autocomplete. However, this should not happen.
|
// just don't autocomplete. However, this should not happen.
|
||||||
if (metadata === undefined) {
|
if (metadata === undefined) {
|
||||||
return line;
|
return line;
|
||||||
}
|
}
|
||||||
//complete an option
|
// complete an option
|
||||||
let next = words.length > 1 ? words[words.length - 1] : '';
|
let next = words.length > 1 ? words[words.length - 1] : '';
|
||||||
let l = [];
|
let l = [];
|
||||||
if (next[0] === '-') {
|
if (next[0] === '-') {
|
||||||
for (let i = 0; i < metadata.options.length; i++) {
|
for (let i = 0; i < metadata.options.length; i++) {
|
||||||
const options = metadata.options[i][0].split(' ');
|
const options = metadata.options[i][0].split(' ');
|
||||||
//if there are multiple options then they will be separated by comma and
|
// if there are multiple options then they will be separated by comma and
|
||||||
//space. The comma should be removed
|
// space. The comma should be removed
|
||||||
if (options[0][options[0].length - 1] === ',') {
|
if (options[0][options[0].length - 1] === ',') {
|
||||||
options[0] = options[0].slice(0, -1);
|
options[0] = options[0].slice(0, -1);
|
||||||
}
|
}
|
||||||
if (words.includes(options[0]) || words.includes(options[1])) {
|
if (words.includes(options[0]) || words.includes(options[1])) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
//First two elements are the flag and the third is the description
|
// First two elements are the flag and the third is the description
|
||||||
//Only autocomplete long
|
// Only autocomplete long
|
||||||
if (options.length > 1 && options[1].indexOf(next) === 0) {
|
if (options.length > 1 && options[1].indexOf(next) === 0) {
|
||||||
l.push(options[1]);
|
l.push(options[1]);
|
||||||
} else if (options[0].indexOf(next) === 0) {
|
} else if (options[0].indexOf(next) === 0) {
|
||||||
@ -59,9 +59,9 @@ async function handleAutocompletionPromise(line) {
|
|||||||
ret.prefix = `${toCommandLine(words.slice(0, -1))} `;
|
ret.prefix = `${toCommandLine(words.slice(0, -1))} `;
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
//Complete an argument
|
// Complete an argument
|
||||||
//Determine the number of positional arguments by counting the number of
|
// Determine the number of positional arguments by counting the number of
|
||||||
//words that don't start with a - less one for the command name
|
// words that don't start with a - less one for the command name
|
||||||
const positionalArgs = words.filter(a => a.indexOf('-') !== 0).length - 1;
|
const positionalArgs = words.filter(a => a.indexOf('-') !== 0).length - 1;
|
||||||
|
|
||||||
let cmdUsage = yargParser(metadata.usage)['_'];
|
let cmdUsage = yargParser(metadata.usage)['_'];
|
||||||
@ -155,20 +155,20 @@ function getArguments(line) {
|
|||||||
if (line[i] === '"') {
|
if (line[i] === '"') {
|
||||||
if (inDoubleQuotes) {
|
if (inDoubleQuotes) {
|
||||||
inDoubleQuotes = false;
|
inDoubleQuotes = false;
|
||||||
//maybe push word to parsed?
|
// maybe push word to parsed?
|
||||||
//currentWord += '"';
|
// currentWord += '"';
|
||||||
} else {
|
} else {
|
||||||
inDoubleQuotes = true;
|
inDoubleQuotes = true;
|
||||||
//currentWord += '"';
|
// currentWord += '"';
|
||||||
}
|
}
|
||||||
} else if (line[i] === '\'') {
|
} else if (line[i] === '\'') {
|
||||||
if (inSingleQuotes) {
|
if (inSingleQuotes) {
|
||||||
inSingleQuotes = false;
|
inSingleQuotes = false;
|
||||||
//maybe push word to parsed?
|
// maybe push word to parsed?
|
||||||
//currentWord += "'";
|
// currentWord += "'";
|
||||||
} else {
|
} else {
|
||||||
inSingleQuotes = true;
|
inSingleQuotes = true;
|
||||||
//currentWord += "'";
|
// currentWord += "'";
|
||||||
}
|
}
|
||||||
} else if (/\s/.test(line[i]) && !(inDoubleQuotes || inSingleQuotes)) {
|
} else if (/\s/.test(line[i]) && !(inDoubleQuotes || inSingleQuotes)) {
|
||||||
if (currentWord !== '') {
|
if (currentWord !== '') {
|
||||||
|
@ -84,8 +84,8 @@ class StatusBarWidget extends BaseWidget {
|
|||||||
// On Windows, bgBlueBright is fine and looks dark enough (Windows is probably in the wrong though)
|
// On Windows, bgBlueBright is fine and looks dark enough (Windows is probably in the wrong though)
|
||||||
// For now, just don't use any colour at all.
|
// For now, just don't use any colour at all.
|
||||||
|
|
||||||
//const textStyle = this.promptActive ? (s) => s : chalk.bgBlueBright.white;
|
// const textStyle = this.promptActive ? (s) => s : chalk.bgBlueBright.white;
|
||||||
//const textStyle = (s) => s;
|
// const textStyle = (s) => s;
|
||||||
const textStyle = this.promptActive ? s => s : chalk.gray;
|
const textStyle = this.promptActive ? s => s : chalk.gray;
|
||||||
|
|
||||||
this.term.drawHLine(this.absoluteInnerX, this.absoluteInnerY, this.innerWidth, textStyle(' '));
|
this.term.drawHLine(this.absoluteInnerX, this.absoluteInnerY, this.innerWidth, textStyle(' '));
|
||||||
|
@ -1027,8 +1027,8 @@ describe('Synchronizer', function() {
|
|||||||
// If we try to disable encryption now, it should throw an error because some items are
|
// If we try to disable encryption now, it should throw an error because some items are
|
||||||
// currently encrypted. They must be decrypted first so that they can be sent as
|
// currently encrypted. They must be decrypted first so that they can be sent as
|
||||||
// plain text to the sync target.
|
// plain text to the sync target.
|
||||||
//let hasThrown = await checkThrowAsync(async () => await encryptionService().disableEncryption());
|
// let hasThrown = await checkThrowAsync(async () => await encryptionService().disableEncryption());
|
||||||
//expect(hasThrown).toBe(true);
|
// expect(hasThrown).toBe(true);
|
||||||
|
|
||||||
// Now supply the password, and decrypt the items
|
// Now supply the password, and decrypt the items
|
||||||
Setting.setObjectKey('encryption.passwordCache', masterKey.id, '123456');
|
Setting.setObjectKey('encryption.passwordCache', masterKey.id, '123456');
|
||||||
|
@ -69,11 +69,11 @@ SyncTargetRegistry.addClass(SyncTargetDropbox);
|
|||||||
|
|
||||||
// const syncTargetId_ = SyncTargetRegistry.nameToId("nextcloud");
|
// const syncTargetId_ = SyncTargetRegistry.nameToId("nextcloud");
|
||||||
const syncTargetId_ = SyncTargetRegistry.nameToId('memory');
|
const syncTargetId_ = SyncTargetRegistry.nameToId('memory');
|
||||||
//const syncTargetId_ = SyncTargetRegistry.nameToId('filesystem');
|
// const syncTargetId_ = SyncTargetRegistry.nameToId('filesystem');
|
||||||
// const syncTargetId_ = SyncTargetRegistry.nameToId('dropbox');
|
// const syncTargetId_ = SyncTargetRegistry.nameToId('dropbox');
|
||||||
const syncDir = `${__dirname}/../tests/sync`;
|
const syncDir = `${__dirname}/../tests/sync`;
|
||||||
|
|
||||||
const sleepTime = syncTargetId_ == SyncTargetRegistry.nameToId('filesystem') ? 1001 : 100;//400;
|
const sleepTime = syncTargetId_ == SyncTargetRegistry.nameToId('filesystem') ? 1001 : 100;// 400;
|
||||||
|
|
||||||
console.info(`Testing with sync target: ${SyncTargetRegistry.idToName(syncTargetId_)}`);
|
console.info(`Testing with sync target: ${SyncTargetRegistry.idToName(syncTargetId_)}`);
|
||||||
|
|
||||||
|
@ -418,8 +418,8 @@ class Application extends BaseApplication {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
/* We need a dummy entry, otherwise the ternary operator to show a
|
// We need a dummy entry, otherwise the ternary operator to show a
|
||||||
* menu item only on a specific OS does not work. */
|
// menu item only on a specific OS does not work.
|
||||||
const noItem = {
|
const noItem = {
|
||||||
type: 'separator',
|
type: 'separator',
|
||||||
visible: false,
|
visible: false,
|
||||||
@ -576,13 +576,13 @@ class Application extends BaseApplication {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const rootMenuFile = {
|
const rootMenuFile = {
|
||||||
/* Using a dummy entry for macOS here, because first menu
|
// Using a dummy entry for macOS here, because first menu
|
||||||
* becomes 'Joplin' and we need a nenu called 'File' later. */
|
// becomes 'Joplin' and we need a nenu called 'File' later.
|
||||||
label: shim.isMac() ? '&JoplinMainMenu' : _('&File'),
|
label: shim.isMac() ? '&JoplinMainMenu' : _('&File'),
|
||||||
/* `&` before one of the char in the label name mean, that
|
// `&` before one of the char in the label name mean, that
|
||||||
* <Alt + F> will open this menu. It's needed becase electron
|
// <Alt + F> will open this menu. It's needed becase electron
|
||||||
* opens the first menu on Alt press if no hotkey assigned.
|
// opens the first menu on Alt press if no hotkey assigned.
|
||||||
* Issue: https://github.com/laurent22/joplin/issues/934 */
|
// Issue: https://github.com/laurent22/joplin/issues/934
|
||||||
submenu: [{
|
submenu: [{
|
||||||
label: _('About Joplin'),
|
label: _('About Joplin'),
|
||||||
visible: shim.isMac() ? true : false,
|
visible: shim.isMac() ? true : false,
|
||||||
|
@ -22,7 +22,7 @@ let hash;
|
|||||||
try {
|
try {
|
||||||
branch = execSync('git rev-parse --abbrev-ref HEAD').toString().trim();
|
branch = execSync('git rev-parse --abbrev-ref HEAD').toString().trim();
|
||||||
hash = execSync('git log --pretty="%h" -1').toString().trim();
|
hash = execSync('git log --pretty="%h" -1').toString().trim();
|
||||||
} catch(err) {
|
} catch (err) {
|
||||||
console.warn('Could not get git info', err);
|
console.warn('Could not get git info', err);
|
||||||
}
|
}
|
||||||
if (typeof branch !== 'undefined' && typeof hash !== 'undefined') {
|
if (typeof branch !== 'undefined' && typeof hash !== 'undefined') {
|
||||||
|
@ -106,7 +106,7 @@ class NotePropertiesDialog extends React.Component {
|
|||||||
|
|
||||||
this.styles_.controlBox = {
|
this.styles_.controlBox = {
|
||||||
marginBottom: '1em',
|
marginBottom: '1em',
|
||||||
color: 'black', //This will apply for the calendar
|
color: 'black', // This will apply for the calendar
|
||||||
};
|
};
|
||||||
|
|
||||||
this.styles_.button = {
|
this.styles_.button = {
|
||||||
|
@ -1840,7 +1840,7 @@ class NoteTextComponent extends React.Component {
|
|||||||
if (this.props.selectedNoteIds.length > 1) {
|
if (this.props.selectedNoteIds.length > 1) {
|
||||||
return this.renderMultiNotes(rootStyle);
|
return this.renderMultiNotes(rootStyle);
|
||||||
} else if (!note || !!note.encryption_applied) {
|
} else if (!note || !!note.encryption_applied) {
|
||||||
//|| (note && !this.props.newNote && this.props.noteId && note.id !== this.props.noteId)) { // note.id !== props.noteId is when the note has not been loaded yet, and the previous one is still in the state
|
// || (note && !this.props.newNote && this.props.noteId && note.id !== this.props.noteId)) { // note.id !== props.noteId is when the note has not been loaded yet, and the previous one is still in the state
|
||||||
return this.renderNoNotes(rootStyle);
|
return this.renderNoNotes(rootStyle);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -386,7 +386,7 @@ function themeStyle(theme) {
|
|||||||
|
|
||||||
// For WebView - must correspond to the properties above
|
// For WebView - must correspond to the properties above
|
||||||
htmlFontSize: `${Math.round(15 * zoomRatio)}px`,
|
htmlFontSize: `${Math.round(15 * zoomRatio)}px`,
|
||||||
htmlLineHeight: '1.6em', //Math.round(20 * zoomRatio) + 'px'
|
htmlLineHeight: '1.6em', // Math.round(20 * zoomRatio) + 'px'
|
||||||
|
|
||||||
htmlCodeFontSize: '.9em',
|
htmlCodeFontSize: '.9em',
|
||||||
};
|
};
|
||||||
|
@ -20,18 +20,18 @@ ArrayUtils.binarySearch = function(items, value) {
|
|||||||
middle = Math.floor((stopIndex + startIndex) / 2);
|
middle = Math.floor((stopIndex + startIndex) / 2);
|
||||||
|
|
||||||
while (items[middle] != value && startIndex < stopIndex) {
|
while (items[middle] != value && startIndex < stopIndex) {
|
||||||
//adjust search area
|
// adjust search area
|
||||||
if (value < items[middle]) {
|
if (value < items[middle]) {
|
||||||
stopIndex = middle - 1;
|
stopIndex = middle - 1;
|
||||||
} else if (value > items[middle]) {
|
} else if (value > items[middle]) {
|
||||||
startIndex = middle + 1;
|
startIndex = middle + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
//recalculate middle
|
// recalculate middle
|
||||||
middle = Math.floor((stopIndex + startIndex) / 2);
|
middle = Math.floor((stopIndex + startIndex) / 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
//make sure it's the right value
|
// make sure it's the right value
|
||||||
return items[middle] != value ? -1 : middle;
|
return items[middle] != value ? -1 : middle;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -63,7 +63,7 @@ class WebDavApi {
|
|||||||
try {
|
try {
|
||||||
// Note: Non-ASCII passwords will throw an error about Latin1 characters - https://github.com/laurent22/joplin/issues/246
|
// Note: Non-ASCII passwords will throw an error about Latin1 characters - https://github.com/laurent22/joplin/issues/246
|
||||||
// Tried various things like the below, but it didn't work on React Native:
|
// Tried various things like the below, but it didn't work on React Native:
|
||||||
//return base64.encode(utf8.encode(this.options_.username() + ':' + this.options_.password()));
|
// return base64.encode(utf8.encode(this.options_.username() + ':' + this.options_.password()));
|
||||||
return base64.encode(`${this.options_.username()}:${this.options_.password()}`);
|
return base64.encode(`${this.options_.username()}:${this.options_.password()}`);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
error.message = `Cannot encode username/password: ${error.message}`;
|
error.message = `Cannot encode username/password: ${error.message}`;
|
||||||
|
@ -67,7 +67,7 @@ class ItemList extends React.Component {
|
|||||||
render() {
|
render() {
|
||||||
const style = this.props.style ? this.props.style : {};
|
const style = this.props.style ? this.props.style : {};
|
||||||
|
|
||||||
//if (!this.props.itemHeight) throw new Error('itemHeight is required');
|
// if (!this.props.itemHeight) throw new Error('itemHeight is required');
|
||||||
|
|
||||||
let itemComps = [];
|
let itemComps = [];
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@ const styles = {
|
|||||||
checkboxIcon: {
|
checkboxIcon: {
|
||||||
fontSize: 20,
|
fontSize: 20,
|
||||||
height: 22,
|
height: 22,
|
||||||
//marginRight: 10,
|
// marginRight: 10,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -57,7 +57,7 @@ class Checkbox extends Component {
|
|||||||
|
|
||||||
if (style && style.display === 'none') return <View />;
|
if (style && style.display === 'none') return <View />;
|
||||||
|
|
||||||
//if (style.display) thStyle.display = style.display;
|
// if (style.display) thStyle.display = style.display;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<TouchableHighlight onPress={() => this.onPress()} style={thStyle}>
|
<TouchableHighlight onPress={() => this.onPress()} style={thStyle}>
|
||||||
|
@ -96,7 +96,7 @@ class NoteBodyViewer extends Component {
|
|||||||
},
|
},
|
||||||
paddingBottom: '3.8em', // Extra bottom padding to make it possible to scroll past the action button (so that it doesn't overlap the text)
|
paddingBottom: '3.8em', // Extra bottom padding to make it possible to scroll past the action button (so that it doesn't overlap the text)
|
||||||
highlightedKeywords: this.props.highlightedKeywords,
|
highlightedKeywords: this.props.highlightedKeywords,
|
||||||
resources: this.props.noteResources, //await shared.attachedResources(bodyToRender),
|
resources: this.props.noteResources, // await shared.attachedResources(bodyToRender),
|
||||||
codeTheme: theme.codeThemeCss,
|
codeTheme: theme.codeThemeCss,
|
||||||
postMessageSyntax: 'window.ReactNativeWebView.postMessage',
|
postMessageSyntax: 'window.ReactNativeWebView.postMessage',
|
||||||
};
|
};
|
||||||
|
@ -30,7 +30,7 @@ class NoteItemComponent extends Component {
|
|||||||
let styles = {
|
let styles = {
|
||||||
listItem: {
|
listItem: {
|
||||||
flexDirection: 'row',
|
flexDirection: 'row',
|
||||||
//height: 40,
|
// height: 40,
|
||||||
borderBottomWidth: 1,
|
borderBottomWidth: 1,
|
||||||
borderBottomColor: theme.dividerColor,
|
borderBottomColor: theme.dividerColor,
|
||||||
alignItems: 'flex-start',
|
alignItems: 'flex-start',
|
||||||
@ -38,7 +38,7 @@ class NoteItemComponent extends Component {
|
|||||||
paddingRight: theme.marginRight,
|
paddingRight: theme.marginRight,
|
||||||
paddingTop: theme.itemMarginTop,
|
paddingTop: theme.itemMarginTop,
|
||||||
paddingBottom: theme.itemMarginBottom,
|
paddingBottom: theme.itemMarginBottom,
|
||||||
//backgroundColor: theme.backgroundColor,
|
// backgroundColor: theme.backgroundColor,
|
||||||
},
|
},
|
||||||
listItemText: {
|
listItemText: {
|
||||||
flex: 1,
|
flex: 1,
|
||||||
|
@ -61,7 +61,7 @@ class NoteListComponent extends Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
filterNotes(notes) {
|
filterNotes(notes) {
|
||||||
const todoFilter = 'all'; //Setting.value('todoFilter');
|
const todoFilter = 'all'; // Setting.value('todoFilter');
|
||||||
if (todoFilter == 'all') return notes;
|
if (todoFilter == 'all') return notes;
|
||||||
|
|
||||||
const now = time.unixMs();
|
const now = time.unixMs();
|
||||||
|
@ -194,7 +194,7 @@ class ConfigScreenComponent extends BaseScreenComponent {
|
|||||||
|
|
||||||
styles.switchSettingControl = Object.assign({}, styles.settingControl);
|
styles.switchSettingControl = Object.assign({}, styles.settingControl);
|
||||||
delete styles.switchSettingControl.color;
|
delete styles.switchSettingControl.color;
|
||||||
//styles.switchSettingControl.width = '20%';
|
// styles.switchSettingControl.width = '20%';
|
||||||
styles.switchSettingControl.flex = 0;
|
styles.switchSettingControl.flex = 0;
|
||||||
|
|
||||||
this.styles_[themeId] = StyleSheet.create(styles);
|
this.styles_[themeId] = StyleSheet.create(styles);
|
||||||
@ -366,7 +366,7 @@ class ConfigScreenComponent extends BaseScreenComponent {
|
|||||||
</View>
|
</View>
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
//throw new Error('Unsupported setting type: ' + md.type);
|
// throw new Error('Unsupported setting type: ' + md.type);
|
||||||
}
|
}
|
||||||
|
|
||||||
return output;
|
return output;
|
||||||
|
@ -410,7 +410,7 @@ class NoteScreenComponent extends BaseScreenComponent {
|
|||||||
|
|
||||||
const format = mimeType == 'image/png' ? 'PNG' : 'JPEG';
|
const format = mimeType == 'image/png' ? 'PNG' : 'JPEG';
|
||||||
reg.logger().info(`Resizing image ${localFilePath}`);
|
reg.logger().info(`Resizing image ${localFilePath}`);
|
||||||
const resizedImage = await ImageResizer.createResizedImage(localFilePath, dimensions.width, dimensions.height, format, 85); //, 0, targetPath);
|
const resizedImage = await ImageResizer.createResizedImage(localFilePath, dimensions.width, dimensions.height, format, 85); // , 0, targetPath);
|
||||||
|
|
||||||
const resizedImagePath = resizedImage.uri;
|
const resizedImagePath = resizedImage.uri;
|
||||||
reg.logger().info('Resized image ', resizedImagePath);
|
reg.logger().info('Resized image ', resizedImagePath);
|
||||||
|
@ -76,7 +76,7 @@ class SideMenuContentComponent extends Component {
|
|||||||
styles.folderButtonSelected = Object.assign({}, styles.folderButton);
|
styles.folderButtonSelected = Object.assign({}, styles.folderButton);
|
||||||
styles.folderButtonSelected.backgroundColor = theme.selectedColor;
|
styles.folderButtonSelected.backgroundColor = theme.selectedColor;
|
||||||
styles.folderIcon = Object.assign({}, theme.icon);
|
styles.folderIcon = Object.assign({}, theme.icon);
|
||||||
styles.folderIcon.color = theme.colorFaded; //'#0072d5';
|
styles.folderIcon.color = theme.colorFaded; // '#0072d5';
|
||||||
styles.folderIcon.paddingTop = 3;
|
styles.folderIcon.paddingTop = 3;
|
||||||
|
|
||||||
styles.sideButton = Object.assign({}, styles.button, { flex: 0 });
|
styles.sideButton = Object.assign({}, styles.button, { flex: 0 });
|
||||||
|
@ -6,7 +6,7 @@ class DatabaseDriverReactNative {
|
|||||||
}
|
}
|
||||||
|
|
||||||
open(options) {
|
open(options) {
|
||||||
//SQLite.DEBUG(true);
|
// SQLite.DEBUG(true);
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
SQLite.openDatabase(
|
SQLite.openDatabase(
|
||||||
{ name: options.name },
|
{ name: options.name },
|
||||||
|
@ -97,10 +97,10 @@ class FileApiDriverLocal {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
if (options.target === 'file') {
|
if (options.target === 'file') {
|
||||||
//output = await fs.copy(path, options.path, { overwrite: true });
|
// output = await fs.copy(path, options.path, { overwrite: true });
|
||||||
output = await this.fsDriver().copy(path, options.path);
|
output = await this.fsDriver().copy(path, options.path);
|
||||||
} else {
|
} else {
|
||||||
//output = await fs.readFile(path, options.encoding);
|
// output = await fs.readFile(path, options.encoding);
|
||||||
output = await this.fsDriver().readFile(path, options.encoding);
|
output = await this.fsDriver().readFile(path, options.encoding);
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
@ -148,7 +148,7 @@ class FileApi {
|
|||||||
setTimestamp(path, timestampMs) {
|
setTimestamp(path, timestampMs) {
|
||||||
this.logger().debug(`setTimestamp ${this.fullPath_(path)}`);
|
this.logger().debug(`setTimestamp ${this.fullPath_(path)}`);
|
||||||
return tryAndRepeat(() => this.driver_.setTimestamp(this.fullPath_(path), timestampMs), this.requestRepeatCount());
|
return tryAndRepeat(() => this.driver_.setTimestamp(this.fullPath_(path), timestampMs), this.requestRepeatCount());
|
||||||
//return this.driver_.setTimestamp(this.fullPath_(path), timestampMs);
|
// return this.driver_.setTimestamp(this.fullPath_(path), timestampMs);
|
||||||
}
|
}
|
||||||
|
|
||||||
mkdir(path) {
|
mkdir(path) {
|
||||||
|
@ -173,7 +173,7 @@ class FsDriverNode extends FsDriverBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async readFileChunk(handle, length, encoding = 'base64') {
|
async readFileChunk(handle, length, encoding = 'base64') {
|
||||||
//let buffer = new Buffer(length);
|
// let buffer = new Buffer(length);
|
||||||
let buffer = Buffer.alloc(length);
|
let buffer = Buffer.alloc(length);
|
||||||
const result = await fs.read(handle, buffer, 0, length, null);
|
const result = await fs.read(handle, buffer, 0, length, null);
|
||||||
if (!result.bytesRead) return null;
|
if (!result.bytesRead) return null;
|
||||||
|
@ -392,10 +392,10 @@ function isSpanStyleBold(attributes) {
|
|||||||
if (style.includes('font-weight: bold;')) {
|
if (style.includes('font-weight: bold;')) {
|
||||||
return true;
|
return true;
|
||||||
} else if (style.search(/font-family:.*,Bold.*;/) != -1) {
|
} else if (style.search(/font-family:.*,Bold.*;/) != -1) {
|
||||||
//console.debug('font-family regex matched');
|
// console.debug('font-family regex matched');
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
//console.debug('Found unsupported style(s) in span tag: %s', style);
|
// console.debug('Found unsupported style(s) in span tag: %s', style);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -696,7 +696,7 @@ function enexXmlToMdArray(stream, resources) {
|
|||||||
if (isSpanWithStyle(nodeAttributes)) {
|
if (isSpanWithStyle(nodeAttributes)) {
|
||||||
state.spanAttributes.push(nodeAttributes);
|
state.spanAttributes.push(nodeAttributes);
|
||||||
if (isSpanStyleBold(nodeAttributes)) {
|
if (isSpanStyleBold(nodeAttributes)) {
|
||||||
//console.debug('Applying style found in span tag: bold')
|
// console.debug('Applying style found in span tag: bold')
|
||||||
section.lines.push('**');
|
section.lines.push('**');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -884,7 +884,7 @@ function enexXmlToMdArray(stream, resources) {
|
|||||||
let attributes = state.spanAttributes.pop();
|
let attributes = state.spanAttributes.pop();
|
||||||
if (isSpanWithStyle(attributes)) {
|
if (isSpanWithStyle(attributes)) {
|
||||||
if (isSpanStyleBold(attributes)) {
|
if (isSpanStyleBold(attributes)) {
|
||||||
//console.debug('Applying style found in span tag (closing): bold')
|
// console.debug('Applying style found in span tag (closing): bold')
|
||||||
section.lines.push('**');
|
section.lines.push('**');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,7 @@ const { time } = require('lib/time-utils.js');
|
|||||||
const Levenshtein = require('levenshtein');
|
const Levenshtein = require('levenshtein');
|
||||||
const md5 = require('md5');
|
const md5 = require('md5');
|
||||||
|
|
||||||
//const Promise = require('promise');
|
// const Promise = require('promise');
|
||||||
const fs = require('fs-extra');
|
const fs = require('fs-extra');
|
||||||
|
|
||||||
function dateToTimestamp(s, zeroIfInvalid = false) {
|
function dateToTimestamp(s, zeroIfInvalid = false) {
|
||||||
|
@ -186,7 +186,7 @@ class OneDriveApi {
|
|||||||
let errorResponseText = await response.text();
|
let errorResponseText = await response.text();
|
||||||
let errorResponse = null;
|
let errorResponse = null;
|
||||||
try {
|
try {
|
||||||
errorResponse = JSON.parse(errorResponseText); //await response.json();
|
errorResponse = JSON.parse(errorResponseText); // await response.json();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
error.message = `OneDriveApi::exec: Cannot parse JSON error: ${errorResponseText} ${error.message}`;
|
error.message = `OneDriveApi::exec: Cannot parse JSON error: ${errorResponseText} ${error.message}`;
|
||||||
throw error;
|
throw error;
|
||||||
@ -249,12 +249,12 @@ class OneDriveApi {
|
|||||||
let response = await this.exec(method, path, query, data);
|
let response = await this.exec(method, path, query, data);
|
||||||
let errorResponseText = await response.text();
|
let errorResponseText = await response.text();
|
||||||
try {
|
try {
|
||||||
let output = JSON.parse(errorResponseText); //await response.json();
|
let output = JSON.parse(errorResponseText); // await response.json();
|
||||||
return output;
|
return output;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
error.message = `OneDriveApi::execJson: Cannot parse JSON: ${errorResponseText} ${error.message}`;
|
error.message = `OneDriveApi::execJson: Cannot parse JSON: ${errorResponseText} ${error.message}`;
|
||||||
throw error;
|
throw error;
|
||||||
//throw new Error('Cannot parse JSON: ' + text);
|
// throw new Error('Cannot parse JSON: ' + text);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/*eslint no-useless-escape: 0*/
|
/* eslint no-useless-escape: 0*/
|
||||||
|
|
||||||
// parseUri 1.2.2
|
// parseUri 1.2.2
|
||||||
// (c) Steven Levithan <stevenlevithan.com>
|
// (c) Steven Levithan <stevenlevithan.com>
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/*eslint no-useless-escape: 0*/
|
/* eslint no-useless-escape: 0*/
|
||||||
|
|
||||||
const { _ } = require('lib/locale');
|
const { _ } = require('lib/locale');
|
||||||
|
|
||||||
|
@ -459,7 +459,7 @@ const reducer = (state = defaultState, action) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//newNotes = Note.sortNotes(newNotes, state.notesOrder, newState.settings.uncompletedTodosOnTop);
|
// newNotes = Note.sortNotes(newNotes, state.notesOrder, newState.settings.uncompletedTodosOnTop);
|
||||||
newNotes = Note.sortNotes(newNotes, stateUtils.notesOrder(state.settings), newState.settings.uncompletedTodosOnTop);
|
newNotes = Note.sortNotes(newNotes, stateUtils.notesOrder(state.settings), newState.settings.uncompletedTodosOnTop);
|
||||||
newState = Object.assign({}, state);
|
newState = Object.assign({}, state);
|
||||||
newState.notes = newNotes;
|
newState.notes = newNotes;
|
||||||
|
@ -10,7 +10,7 @@ reg.syncTargets_ = {};
|
|||||||
|
|
||||||
reg.logger = () => {
|
reg.logger = () => {
|
||||||
if (!reg.logger_) {
|
if (!reg.logger_) {
|
||||||
//console.warn('Calling logger before it is initialized');
|
// console.warn('Calling logger before it is initialized');
|
||||||
return new Logger();
|
return new Logger();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -273,7 +273,7 @@ class EncryptionService {
|
|||||||
ks: 128, // Key size - "128 bits should be secure enough"
|
ks: 128, // Key size - "128 bits should be secure enough"
|
||||||
ts: 64, // ???
|
ts: 64, // ???
|
||||||
mode: 'ocb2', // The cipher mode is a standard for how to use AES and other algorithms to encrypt and authenticate your message. OCB2 mode is slightly faster and has more features, but CCM mode has wider support because it is not patented.
|
mode: 'ocb2', // The cipher mode is a standard for how to use AES and other algorithms to encrypt and authenticate your message. OCB2 mode is slightly faster and has more features, but CCM mode has wider support because it is not patented.
|
||||||
//"adata":"", // Associated Data - not needed?
|
// "adata":"", // Associated Data - not needed?
|
||||||
cipher: 'aes',
|
cipher: 'aes',
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
@ -568,7 +568,7 @@ class Api {
|
|||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
|
||||||
async downloadImage_(url /*, allowFileProtocolImages */) {
|
async downloadImage_(url /* , allowFileProtocolImages */) {
|
||||||
const tempDir = Setting.value('tempDir');
|
const tempDir = Setting.value('tempDir');
|
||||||
|
|
||||||
const isDataUrl = url && url.toLowerCase().indexOf('data:') === 0;
|
const isDataUrl = url && url.toLowerCase().indexOf('data:') === 0;
|
||||||
|
@ -255,7 +255,7 @@ function shimInit() {
|
|||||||
shim.fetchBlob = async function(url, options) {
|
shim.fetchBlob = async function(url, options) {
|
||||||
if (!options || !options.path) throw new Error('fetchBlob: target file path is missing');
|
if (!options || !options.path) throw new Error('fetchBlob: target file path is missing');
|
||||||
if (!options.method) options.method = 'GET';
|
if (!options.method) options.method = 'GET';
|
||||||
//if (!('maxRetry' in options)) options.maxRetry = 5;
|
// if (!('maxRetry' in options)) options.maxRetry = 5;
|
||||||
|
|
||||||
const urlParse = require('url').parse;
|
const urlParse = require('url').parse;
|
||||||
|
|
||||||
|
@ -548,7 +548,7 @@ class Synchronizer {
|
|||||||
if (!BaseItem.isSystemPath(remote.path)) continue; // The delta API might return things like the .sync, .resource or the root folder
|
if (!BaseItem.isSystemPath(remote.path)) continue; // The delta API might return things like the .sync, .resource or the root folder
|
||||||
|
|
||||||
const loadContent = async () => {
|
const loadContent = async () => {
|
||||||
let task = await this.downloadQueue_.waitForResult(path); //await this.api().get(path);
|
let task = await this.downloadQueue_.waitForResult(path); // await this.api().get(path);
|
||||||
if (task.error) throw task.error;
|
if (task.error) throw task.error;
|
||||||
if (!task.result) return null;
|
if (!task.result) return null;
|
||||||
return await BaseItem.unserialize(task.result);
|
return await BaseItem.unserialize(task.result);
|
||||||
|
@ -634,7 +634,7 @@ class AppComponent extends React.Component {
|
|||||||
}, 5);
|
}, 5);
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch(e) {
|
} catch (e) {
|
||||||
reg.logger().error('Error in ShareExtension.data', e);
|
reg.logger().error('Error in ShareExtension.data', e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -449,7 +449,7 @@ function markdownToHtml(md, templateParams) {
|
|||||||
const anchorName = headingTextToAnchorName(token.content, doneNames);
|
const anchorName = headingTextToAnchorName(token.content, doneNames);
|
||||||
doneNames.push(anchorName);
|
doneNames.push(anchorName);
|
||||||
const anchorTokens = createAnchorTokens(anchorName);
|
const anchorTokens = createAnchorTokens(anchorName);
|
||||||
//token.children = anchorTokens.concat(token.children);
|
// token.children = anchorTokens.concat(token.children);
|
||||||
token.children = token.children.concat(anchorTokens);
|
token.children = token.children.concat(anchorTokens);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,7 @@ toolUtils.downloadFile = function(url, targetPath) {
|
|||||||
if (response.statusCode !== 200) reject(new Error(`HTTP error ${response.statusCode}`));
|
if (response.statusCode !== 200) reject(new Error(`HTTP error ${response.statusCode}`));
|
||||||
response.pipe(file);
|
response.pipe(file);
|
||||||
file.on('finish', function() {
|
file.on('finish', function() {
|
||||||
//file.close();
|
// file.close();
|
||||||
resolve();
|
resolve();
|
||||||
});
|
});
|
||||||
}).on('error', (error) => {
|
}).on('error', (error) => {
|
||||||
@ -74,7 +74,7 @@ toolUtils.fileExists = async function(filePath) {
|
|||||||
fs.stat(filePath, function(err) {
|
fs.stat(filePath, function(err) {
|
||||||
if (err == null) {
|
if (err == null) {
|
||||||
resolve(true);
|
resolve(true);
|
||||||
} else if(err.code == 'ENOENT') {
|
} else if (err.code == 'ENOENT') {
|
||||||
resolve(false);
|
resolve(false);
|
||||||
} else {
|
} else {
|
||||||
reject(err);
|
reject(err);
|
||||||
|
Loading…
Reference in New Issue
Block a user