Compare commits

...

3 Commits

Author SHA1 Message Date
5d9b412973 Add C-; toggleTodo key and actions
All checks were successful
continuous-integration/drone/push Build is passing
Toggles between [ ] -> [x] -> none
2021-08-07 20:18:38 +02:00
0cd50f7766 Small clean ups 2021-08-07 20:18:30 +02:00
8e101418f3 Improve alignment of checkbox 2021-08-07 20:18:08 +02:00
3 changed files with 27 additions and 5 deletions

View File

@ -383,7 +383,7 @@ mark {
}
.content input[type="checkbox"] {
vertical-align: text-top;
vertical-align: baseline;
}
.lighter {

View File

@ -121,6 +121,7 @@ func NewFilePages(dirname string, index bleve.Index) PagesRepository {
}
}
}()
return fp
}
@ -134,7 +135,7 @@ func convertBlocksToListItems(current string, blocks BlockResponse, indent int)
ID: child,
Indented: indent,
Text: blocks.Texts[child],
Fold: "open", // TODO: keep Fold state somewhere
Fold: "open",
Hidden: false,
})
listItems = append(listItems, l...)
@ -159,6 +160,7 @@ func (fp *FilePages) Get(name string) Page {
var to titleOption
pageNameDate, err := ParseDatePageName(name)
if err == nil {
to.date = true
to.timeObj = pageNameDate
@ -321,7 +323,7 @@ func (fp *FilePages) save(msg saveMessage) error {
sw.Start("git")
err = saveWithGit(fp, p, summary, author)
if err != nil {
log.Printf("Error while saving to git: %w", err)
log.Printf("Error while saving to git: %s", err)
// return fmt.Errorf("while saving to git: %w", err)
}
sw.Stop()
@ -584,7 +586,6 @@ func saveLinksIncremental(dirname, title string) error {
return err
}
f.Close()
return nil
}

View File

@ -59,6 +59,7 @@ function editor(root, inputData, options) {
normalKeymap.mapKey('Tab', 'indentBlock')
normalKeymap.mapKey('S-Tab', 'indentBlock')
normalKeymap.mapKey('C-.', 'toggleBlock')
normalKeymap.mapKey('C-;', 'toggleTodo')
function createStore(inputData) {
let data = [
@ -195,7 +196,9 @@ function editor(root, inputData, options) {
expandBlock,
collapseBlock,
toggleBlock
toggleBlock,
toggleTodo
};
root.classList.add('root')
@ -659,6 +662,24 @@ function editor(root, inputData, options) {
return toggleBlock(event, false)
}
function toggleTodo(event) {
store.update(cursor.getId(store), function (item) {
const res = item.text.match(/^#\[\[(TODO|DONE)\]\]/)
if (res) {
if (res[1] === 'TODO') {
item.text = item.text.replace(/#\[\[TODO\]\]\s*/, '#[[DONE]] ')
} else {
item.text = item.text.replace(/#\[\[DONE\]\]\s*/, '')
}
} else {
item.text = '#[[TODO]] ' + item.text
}
return item
})
trigger('change')
return false
}
function countBraces(sset, as) {
let set = _(sset).chain().split('').value()
let defaults = {}