mirror of
https://github.com/laurent22/joplin.git
synced 2024-11-27 08:21:03 +02:00
Electron: Fixes #626: Auto-completion for indented items
This commit is contained in:
parent
a67600d264
commit
599f4ccef4
@ -615,6 +615,18 @@ class NoteTextComponent extends React.Component {
|
||||
document.querySelector('#note-editor').addEventListener('paste', this.onEditorPaste_, true);
|
||||
document.querySelector('#note-editor').addEventListener('keydown', this.onEditorKeyDown_);
|
||||
|
||||
const lineLeftSpaces = function(line) {
|
||||
let output = '';
|
||||
for (let i = 0; i < line.length; i++) {
|
||||
if ([' ', '\t'].indexOf(line[i]) >= 0) {
|
||||
output += line[i];
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return output;
|
||||
}
|
||||
|
||||
// Disable Markdown auto-completion (eg. auto-adding a dash after a line with a dash.
|
||||
// https://github.com/ajaxorg/ace/issues/2754
|
||||
const that = this; // The "this" within the function below refers to something else
|
||||
@ -622,12 +634,15 @@ class NoteTextComponent extends React.Component {
|
||||
const ls = that.state.lastKeys;
|
||||
if (ls.length >= 2 && ls[ls.length - 1] === 'Enter' && ls[ls.length - 2] === 'Enter') return this.$getIndent(line);
|
||||
|
||||
if (line.indexOf('- [ ] ') === 0 || line.indexOf('- [x] ') === 0 || line.indexOf('- [X] ') === 0) return '- [ ] ';
|
||||
if (line.indexOf('- ') === 0) return '- ';
|
||||
if (line.indexOf('* ') === 0) return '* ';
|
||||
const leftSpaces = lineLeftSpaces(line);
|
||||
const lineNoLeftSpaces = line.trimLeft();
|
||||
|
||||
const bulletNumber = markdownUtils.olLineNumber(line);
|
||||
if (bulletNumber) return (bulletNumber + 1) + '. ';
|
||||
if (lineNoLeftSpaces.indexOf('- [ ] ') === 0 || lineNoLeftSpaces.indexOf('- [x] ') === 0 || lineNoLeftSpaces.indexOf('- [X] ') === 0) return leftSpaces + '- [ ] ';
|
||||
if (lineNoLeftSpaces.indexOf('- ') === 0) return leftSpaces + '- ';
|
||||
if (lineNoLeftSpaces.indexOf('* ') === 0) return leftSpaces + '* ';
|
||||
|
||||
const bulletNumber = markdownUtils.olLineNumber(lineNoLeftSpaces);
|
||||
if (bulletNumber) return leftSpaces + (bulletNumber + 1) + '. ';
|
||||
|
||||
return this.$getIndent(line);
|
||||
};
|
||||
|
@ -280,7 +280,7 @@ Please see the [donation page](https://joplin.cozic.net/donate/) for information
|
||||
- For general discussion about Joplin, user support, software development questions, and to discuss new features, go to the [Joplin Forum](https://discourse.joplin.cozic.net/). It is possible to login with your GitHub account.
|
||||
- Also see here for information about [the latest releases and general news](https://discourse.joplin.cozic.net/c/news).
|
||||
- For bug reports and feature requests, go to the [GitHub Issue Tracker](https://github.com/laurent22/joplin/issues).
|
||||
- The latest news are often posted [on this Twitter account](https://twitter.com/laurent2233).
|
||||
- The latest news are posted [on the Patreon page](https://www.patreon.com/joplin).
|
||||
|
||||
# Contributing
|
||||
|
||||
|
@ -474,7 +474,7 @@ $$
|
||||
<li>For general discussion about Joplin, user support, software development questions, and to discuss new features, go to the <a href="https://discourse.joplin.cozic.net/">Joplin Forum</a>. It is possible to login with your GitHub account.</li>
|
||||
<li>Also see here for information about <a href="https://discourse.joplin.cozic.net/c/news">the latest releases and general news</a>.</li>
|
||||
<li>For bug reports and feature requests, go to the <a href="https://github.com/laurent22/joplin/issues">GitHub Issue Tracker</a>.</li>
|
||||
<li>The latest news are often posted <a href="https://twitter.com/laurent2233">on this Twitter account</a>.</li>
|
||||
<li>The latest news are posted <a href="https://www.patreon.com/joplin">on the Patreon page</a>.</li>
|
||||
</ul>
|
||||
<h1 id="contributing">Contributing</h1>
|
||||
<p>Please see the guide for information on how to contribute to the development of Joplin: <a href="https://github.com/laurent22/joplin/blob/master/CONTRIBUTING.md">https://github.com/laurent22/joplin/blob/master/CONTRIBUTING.md</a></p>
|
||||
|
Loading…
Reference in New Issue
Block a user