mirror of
https://github.com/ankitects/anki.git
synced 2026-01-07 02:53:54 -05:00
Added: Edit button functionality
This commit is contained in:
parent
0af6b4d2ef
commit
f91ba1075b
3 changed files with 18 additions and 4 deletions
|
|
@ -34,6 +34,7 @@ service FrontendService {
|
|||
|
||||
// Plays the listed AV tags
|
||||
rpc PlayAVTags(PlayAVTagsRequest) returns (generic.Empty);
|
||||
rpc displayEditMenu(DisplayEditMenuRequest) returns (generic.Empty);
|
||||
}
|
||||
|
||||
service BackendFrontendService {}
|
||||
|
|
@ -50,4 +51,8 @@ message SetSchedulingStatesRequest {
|
|||
|
||||
message PlayAVTagsRequest {
|
||||
repeated card_rendering.AVTag tags = 1;
|
||||
}
|
||||
|
||||
message DisplayEditMenuRequest {
|
||||
optional int64 cid = 1;
|
||||
}
|
||||
|
|
@ -28,10 +28,10 @@ import aqt
|
|||
import aqt.main
|
||||
import aqt.operations
|
||||
from anki import hooks
|
||||
from anki.cards import Card
|
||||
from anki.cards import Card, CardId
|
||||
from anki.collection import OpChanges, OpChangesOnly, Progress, SearchNode
|
||||
from anki.decks import UpdateDeckConfigs
|
||||
from anki.frontend_pb2 import PlayAVTagsRequest
|
||||
from anki.frontend_pb2 import DisplayEditMenuRequest, PlayAVTagsRequest
|
||||
from anki.scheduler.v3 import SchedulingStatesWithContext, SetSchedulingStatesRequest
|
||||
from anki.scheduler_pb2 import NextCardDataResponse
|
||||
from anki.template import (
|
||||
|
|
@ -698,6 +698,14 @@ def play_avtags():
|
|||
play_tags(av_tags_to_native(req.tags))
|
||||
|
||||
|
||||
def display_edit_menu():
|
||||
req = DisplayEditMenuRequest.FromString(request.data)
|
||||
aqt.mw.reviewer.card = aqt.mw.col.get_card(
|
||||
CardId(req.cid) if req.HasField("cid") else None
|
||||
)
|
||||
aqt.mw.taskman.run_on_main(aqt.mw.onEditCurrent)
|
||||
|
||||
|
||||
post_handler_list = [
|
||||
congrats_info,
|
||||
get_deck_configs_for_update,
|
||||
|
|
@ -716,6 +724,7 @@ post_handler_list = [
|
|||
save_custom_colours,
|
||||
next_card_data,
|
||||
play_avtags,
|
||||
display_edit_menu,
|
||||
]
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -6,11 +6,11 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|||
import "./index.scss";
|
||||
|
||||
import AnswerButton from "./AnswerButton.svelte";
|
||||
import { bridgeCommand } from "@tslib/bridgecommand";
|
||||
import * as tr from "@generated/ftl";
|
||||
import type { ReviewerState } from "../reviewer";
|
||||
import Remaining from "./Remaining.svelte";
|
||||
import More from "./More.svelte";
|
||||
import { displayEditMenu } from "@generated/backend";
|
||||
|
||||
export let state: ReviewerState;
|
||||
|
||||
|
|
@ -26,7 +26,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|||
<div class="disappearing edit">
|
||||
<button
|
||||
title={tr.actionsShortcutKey({ val: "E" })}
|
||||
on:click={() => bridgeCommand("edit")}
|
||||
on:click={() => displayEditMenu({ cid: state.currentCard?.card?.id })}
|
||||
>
|
||||
{tr.studyingEdit()}
|
||||
</button>
|
||||
|
|
|
|||
Loading…
Reference in a new issue