mirror of
https://github.com/laurent22/joplin.git
synced 2024-12-24 10:27:10 +02:00
Merge branch 'dev' of github.com:laurent22/joplin into dev
This commit is contained in:
commit
1ef380d995
@ -105,7 +105,11 @@ describe('models_BaseItem', function() {
|
||||
}));
|
||||
|
||||
it('should serialize and unserialize properties that contain new lines', asyncTest(async () => {
|
||||
const note = await Note.save({ title: 'note', source_url: '\nhttps://joplinapp.org/\n' });
|
||||
const sourceUrl = `
|
||||
https://joplinapp.org/ \\n
|
||||
`;
|
||||
|
||||
const note = await Note.save({ title: 'note', source_url: sourceUrl });
|
||||
|
||||
const noteBefore = await Note.load(note.id);
|
||||
const serialized = await Note.serialize(noteBefore);
|
||||
@ -113,4 +117,18 @@ describe('models_BaseItem', function() {
|
||||
|
||||
expect(noteAfter).toEqual(noteBefore);
|
||||
}));
|
||||
|
||||
it('should not serialize the note title and body', asyncTest(async () => {
|
||||
const note = await Note.save({ title: 'my note', body: `one line
|
||||
two line
|
||||
three line \\n no escape` });
|
||||
|
||||
const noteBefore = await Note.load(note.id);
|
||||
const serialized = await Note.serialize(noteBefore);
|
||||
expect(serialized.indexOf(`my note
|
||||
|
||||
one line
|
||||
two line
|
||||
three line \\n no escape`)).toBe(0);
|
||||
}));
|
||||
});
|
||||
|
@ -41,14 +41,14 @@ export default function styles(props: Props) {
|
||||
leftIcon: {
|
||||
fontSize: iconSize,
|
||||
position: 'relative',
|
||||
top: 2,
|
||||
top: 1,
|
||||
color: theme.color3,
|
||||
},
|
||||
rightIcon: {
|
||||
fontSize: iconSize - 1,
|
||||
borderLeft: 'none',
|
||||
position: 'relative',
|
||||
top: 2,
|
||||
top: 1,
|
||||
color: theme.color3,
|
||||
},
|
||||
};
|
||||
|
@ -40,6 +40,7 @@ class ToolbarBaseComponent extends React.Component<Props, any> {
|
||||
const o = this.props.items[i];
|
||||
let key = o.iconName ? o.iconName : '';
|
||||
key += o.title ? o.title : '';
|
||||
key += o.name ? o.name : '';
|
||||
const itemType = !('type' in o) ? 'button' : o.type;
|
||||
|
||||
if (!key) key = `${o.type}_${i}`;
|
||||
|
@ -260,7 +260,13 @@ class BaseItem extends BaseModel {
|
||||
propValue = `${propValue}`;
|
||||
}
|
||||
|
||||
return propValue.replace(/\n/g, '\\n').replace(/\r/g, '\\r');
|
||||
if (propName === 'body') return propValue;
|
||||
|
||||
return propValue
|
||||
.replace(/\\n/g, '\\\\n')
|
||||
.replace(/\\r/g, '\\\\r')
|
||||
.replace(/\n/g, '\\n')
|
||||
.replace(/\r/g, '\\r');
|
||||
}
|
||||
|
||||
static unserialize_format(type, propName, propValue) {
|
||||
@ -281,7 +287,14 @@ class BaseItem extends BaseModel {
|
||||
propValue = Database.formatValue(ItemClass.fieldType(propName), propValue);
|
||||
}
|
||||
|
||||
return typeof propValue === 'string' ? propValue.replace(/\\n/g, '\n').replace(/\\r/g, '\r') : propValue;
|
||||
if (propName === 'body') return propValue;
|
||||
|
||||
return typeof propValue === 'string' ? propValue
|
||||
.replace(/\\n/g, '\n')
|
||||
.replace(/\\r/g, '\r')
|
||||
.replace(/\\\n/g, '\\n')
|
||||
.replace(/\\\r/g, '\\r')
|
||||
: propValue;
|
||||
}
|
||||
|
||||
static async serialize(item, shownKeys = null) {
|
||||
|
@ -1,6 +1,7 @@
|
||||
import AsyncActionQueue from '../../AsyncActionQueue';
|
||||
import shim from '../../shim';
|
||||
import { _ } from '../../locale';
|
||||
import { toSystemSlashes } from '../../path-utils';
|
||||
const Logger = require('../../Logger').default;
|
||||
const Setting = require('../../models/Setting').default;
|
||||
const Resource = require('../../models/Resource');
|
||||
@ -157,6 +158,8 @@ export default class ResourceEditWatcher {
|
||||
if (!this.watcher_) {
|
||||
this.watcher_ = this.chokidar_.watch(fileToWatch);
|
||||
this.watcher_.on('all', async (event: any, path: string) => {
|
||||
path = toSystemSlashes(path, 'linux');
|
||||
|
||||
this.logger().info(`ResourceEditWatcher: Event: ${event}: ${path}`);
|
||||
|
||||
if (event === 'unlink') {
|
||||
@ -183,11 +186,13 @@ export default class ResourceEditWatcher {
|
||||
//
|
||||
// @ts-ignore Leave unused path variable
|
||||
this.watcher_.on('raw', async (event: string, path: string, options: any) => {
|
||||
this.logger().debug(`ResourceEditWatcher: Raw event: ${event}: ${options.watchedPath}`);
|
||||
const watchedPath = toSystemSlashes(options.watchedPath, 'linux');
|
||||
|
||||
this.logger().debug(`ResourceEditWatcher: Raw event: ${event}: ${watchedPath}`);
|
||||
if (event === 'rename') {
|
||||
this.watcher_.unwatch(options.watchedPath);
|
||||
this.watcher_.add(options.watchedPath);
|
||||
handleChangeEvent(options.watchedPath);
|
||||
this.watcher_.unwatch(watchedPath);
|
||||
this.watcher_.add(watchedPath);
|
||||
handleChangeEvent(watchedPath);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
@ -218,7 +223,7 @@ export default class ResourceEditWatcher {
|
||||
if (!(await Resource.isReady(resource))) throw new Error(_('This attachment is not downloaded or not decrypted yet'));
|
||||
const sourceFilePath = Resource.fullPath(resource);
|
||||
const tempDir = await this.tempDir();
|
||||
const editFilePath = await shim.fsDriver().findUniqueFilename(`${tempDir}/${Resource.friendlySafeFilename(resource)}`);
|
||||
const editFilePath = toSystemSlashes(await shim.fsDriver().findUniqueFilename(`${tempDir}/${Resource.friendlySafeFilename(resource)}`), 'linux');
|
||||
await shim.fsDriver().copy(sourceFilePath, editFilePath);
|
||||
const stat = await shim.fsDriver().stat(editFilePath);
|
||||
|
||||
|
@ -409,10 +409,16 @@ export default class MdToHtml {
|
||||
outputCodeHtml = markdownIt.utils.escapeHtml(trimmedStr);
|
||||
}
|
||||
|
||||
return {
|
||||
wrapCode: false,
|
||||
html: `<div class="joplin-editable">${sourceBlockHtml}<pre class="hljs"><code>${outputCodeHtml}</code></pre></div>`,
|
||||
};
|
||||
const html = `<div class="joplin-editable">${sourceBlockHtml}<pre class="hljs"><code>${outputCodeHtml}</code></pre></div>`;
|
||||
|
||||
if (rules.fence) {
|
||||
return {
|
||||
wrapCode: false,
|
||||
html: html,
|
||||
};
|
||||
} else {
|
||||
return html;
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user