You've already forked joplin
mirror of
https://github.com/laurent22/joplin.git
synced 2025-09-16 08:56:40 +02:00
Save scroll position in notes
This commit is contained in:
@@ -73,6 +73,8 @@ class NoteScreenComponent extends BaseScreenComponent {
|
|||||||
isLoading: true,
|
isLoading: true,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
this.bodyScrollTop_ = 0;
|
||||||
|
|
||||||
this.saveButtonHasBeenShown_ = false;
|
this.saveButtonHasBeenShown_ = false;
|
||||||
|
|
||||||
this.backHandler = () => {
|
this.backHandler = () => {
|
||||||
@@ -306,7 +308,7 @@ class NoteScreenComponent extends BaseScreenComponent {
|
|||||||
return body;
|
return body;
|
||||||
}
|
}
|
||||||
|
|
||||||
function markdownToHtml(body, style) {
|
const markdownToHtml = (body, style) => {
|
||||||
// https://necolas.github.io/normalize.css/
|
// https://necolas.github.io/normalize.css/
|
||||||
const normalizeCss = `
|
const normalizeCss = `
|
||||||
html{line-height:1.15;-ms-text-size-adjust:100%;-webkit-text-size-adjust:100%}body{margin:0}
|
html{line-height:1.15;-ms-text-size-adjust:100%;-webkit-text-size-adjust:100%}body{margin:0}
|
||||||
@@ -374,11 +376,15 @@ class NoteScreenComponent extends BaseScreenComponent {
|
|||||||
let elementId = 1;
|
let elementId = 1;
|
||||||
while (html.indexOf('°°JOP°') >= 0) {
|
while (html.indexOf('°°JOP°') >= 0) {
|
||||||
html = html.replace(/°°JOP°CHECKBOX°([A-Z]+)°(\d+)°°/, function(v, type, index) {
|
html = html.replace(/°°JOP°CHECKBOX°([A-Z]+)°(\d+)°°/, function(v, type, index) {
|
||||||
const js = "postMessage('checkboxclick_" + type + '_' + index + "'); this.textContent = this.textContent == '☐' ? '☑' : '☐';";
|
const js = "postMessage('checkboxclick:" + type + '_' + index + "'); this.textContent = this.textContent == '☐' ? '☑' : '☐'; return false;";
|
||||||
return '<a href="#" onclick="' + js + '" class="checkbox">' + (type == 'NOTICK' ? '☐' : '☑') + '</a>';
|
return '<a href="#" onclick="' + js + '" class="checkbox">' + (type == 'NOTICK' ? '☐' : '☑') + '</a>';
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let scriptHtml = '<script>document.body.scrollTop = ' + this.bodyScrollTop_ + ';</script>';
|
||||||
|
|
||||||
|
html = '<body onscroll="postMessage(\'bodyscroll:\' + document.body.scrollTop);">' + html + scriptHtml + '</body>';
|
||||||
|
|
||||||
return html;
|
return html;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -391,12 +397,15 @@ class NoteScreenComponent extends BaseScreenComponent {
|
|||||||
|
|
||||||
reg.logger().info('postMessage received: ' + msg);
|
reg.logger().info('postMessage received: ' + msg);
|
||||||
|
|
||||||
if (msg.indexOf('checkboxclick_') === 0) {
|
if (msg.indexOf('checkboxclick:') === 0) {
|
||||||
msg = msg.split('_');
|
msg = msg.split(':');
|
||||||
let index = Number(msg[msg.length - 1]);
|
let index = Number(msg[msg.length - 1]);
|
||||||
let currentState = msg[msg.length - 2]; // Not really needed but keep it anyway
|
let currentState = msg[msg.length - 2]; // Not really needed but keep it anyway
|
||||||
const newBody = toggleTickAt(note.body, index);
|
const newBody = toggleTickAt(note.body, index);
|
||||||
this.saveOneProperty('body', newBody);
|
this.saveOneProperty('body', newBody);
|
||||||
|
} else if (msg.indexOf('bodyscroll:') === 0) {
|
||||||
|
msg = msg.split(':');
|
||||||
|
this.bodyScrollTop_ = Number(msg[1]);
|
||||||
} else {
|
} else {
|
||||||
Linking.openURL(msg);
|
Linking.openURL(msg);
|
||||||
}
|
}
|
||||||
|
@@ -50,12 +50,7 @@ class NotesScreenComponent extends BaseScreenComponent {
|
|||||||
parentId: parent.id,
|
parentId: parent.id,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (source == props.notesSource) {
|
if (source == props.notesSource) return;
|
||||||
console.info('NO SOURCE CHAGNE');
|
|
||||||
console.info(source);
|
|
||||||
console.info(props.notesSource);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
let notes = [];
|
let notes = [];
|
||||||
if (props.notesParentType == 'Folder') {
|
if (props.notesParentType == 'Folder') {
|
||||||
@@ -103,7 +98,7 @@ class NotesScreenComponent extends BaseScreenComponent {
|
|||||||
{ title: _('Edit notebook'), onPress: () => { this.editFolder_onPress(this.props.selectedFolderId); } },
|
{ title: _('Edit notebook'), onPress: () => { this.editFolder_onPress(this.props.selectedFolderId); } },
|
||||||
];
|
];
|
||||||
} else {
|
} else {
|
||||||
return []; // TODO
|
return []; // For tags - TODO
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -113,6 +113,8 @@ class SearchScreenComponent extends BaseScreenComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
if (!this.isMounted_) return null;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<View style={this.styles().screen}>
|
<View style={this.styles().screen}>
|
||||||
<ScreenHeader title={_('Search')}/>
|
<ScreenHeader title={_('Search')}/>
|
||||||
|
@@ -208,10 +208,8 @@ class SideMenuContentComponent extends Component {
|
|||||||
|
|
||||||
items.push(<View style={{ height: globalStyle.marginBottom }} key='bottom_padding_hack'/>);
|
items.push(<View style={{ height: globalStyle.marginBottom }} key='bottom_padding_hack'/>);
|
||||||
|
|
||||||
// onLayout={(event) => this.onLayout(event)}
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<View style={{flex:1}}>
|
<View style={{flex:1, borderRightWidth: 1, borderRightColor: globalStyle.dividerColor }}>
|
||||||
<View style={{flexDirection:'row'}}>
|
<View style={{flexDirection:'row'}}>
|
||||||
<Image style={{flex:1, height: 150}} source={require('../images/SideMenuHeader.png')} />
|
<Image style={{flex:1, height: 150}} source={require('../images/SideMenuHeader.png')} />
|
||||||
</View>
|
</View>
|
||||||
|
Reference in New Issue
Block a user