kelciour / edit-field-during-review

3 stars 1 forks source link

the edit-field-during-review add-on #16

Closed Seven430 closed 3 weeks ago

Seven430 commented 3 weeks ago

Thank you for your edit-field-during-review add-on. I'm not sure if it's appropriate to bother you here with a question that's been troubling me regarding the edit-field-during-review add-on. When using the following code in the template, it allows modifications but fails to save:

{{edit:Frontside}}
Seven430 commented 3 weeks ago

I’m a beginner, so if you’re available, could you please take a look? I would appreciate it.

kelciour commented 3 weeks ago

The add-on saves changes when the editable element loses focus by calling this JavaScript code.

pycmd(`ankisave#${fld}#${nid}#${value}`);

fld is the name of the field nid is the id of the note

Here's an example from https://github.com/kelciour/edit-field-during-review/issues/14

...

<div id="elem" hidden>{{edit:Back}}</div>

<script>
function saveScrollPosition() {
  elem = document.querySelector('#elem [contenteditable]');
  fld = "Back";
  nid = elem.dataset.nid;
  value = window.scrollY;
  pycmd(`ankisave#${fld}#${nid}#${value}`);
}

document.onkeyup = function(event) {
  if (event.code == 'KeyD' && (event.ctrlKey || event.metaKey)) {
    saveScrollPosition();
  }
};
</script>
Seven430 commented 3 weeks ago

Thank you for responding so quickly.

Seven430 commented 3 weeks ago

Could you please let me know what the format of pycmd is when I use Edit Field During Review (Cloze)?

kelciour commented 3 weeks ago

It's pycmd(`EFDRC#${nid}#${fld}#${value}`);

https://github.com/BlueGreenMagick/Edit-Field-During-Review-Cloze/blob/8fdc898e97f5114ddd79f5321db2f6bb7940c214/src/addon/reviewer.py#L147C28-L147C34

Seven430 commented 3 weeks ago

Thanks a million