37Rb / nextcloud-hledger

Plain Text Accounting on Nextcloud
GNU Affero General Public License v3.0
13 stars 2 forks source link

Navigate from a transaction to edit it #2

Closed 37Rb closed 3 years ago

37Rb commented 3 years ago

Like ‘E’ in hledger-ui. Go right to the transaction. Don’t make the user search for it.

See https://help.nextcloud.com/t/how-to-include-a-text-editor-in-my-nextcloud-app/113843 for how to use the built in text editor.

37Rb commented 3 years ago

Also some nodes I had in a temp file...

OCA.Viewer.open({path: '/HLedger/journal.txt'});

// Need to wait until it's loaded

var jqeditor = $("#editor");
var editor = jqeditor.get(0);
var textnode = $("code", jqeditor).get(0);

var match = textnode.innerText.match('2021-04-01 CITIZENS MTG PMT 8104577286');

var range = document.createRange();
range.setStart(textnode.firstChild, match.index);
range.setEnd(textnode.firstChild, match.index + match[0].length);

var selection = window.getSelection();
selection.removeAllRanges();
selection.addRange(range);

editor.scroll(0, range.getBoundingClientRect().top - textnode.getBoundingClientRect().top);
37Rb commented 3 years ago

https://github.com/37Rb/nextcloud-hledger/commit/783bd8b0f8b27339269aa2875ff7947abf6948a0 https://github.com/37Rb/nextcloud-hledger/commit/b1c53c142518384027d73c7c09eeb4f53a50fc18 https://github.com/37Rb/nextcloud-hledger/commit/a3f7b7cfceb0639548fa5cb0b023cb7f235df9c4 https://github.com/37Rb/nextcloud-hledger/commit/594943ffd6ce6e8a9311392b192d94cdebee71b5