mirror of
https://github.com/ankitects/anki.git
synced 2026-01-10 12:33:55 -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
|
// Plays the listed AV tags
|
||||||
rpc PlayAVTags(PlayAVTagsRequest) returns (generic.Empty);
|
rpc PlayAVTags(PlayAVTagsRequest) returns (generic.Empty);
|
||||||
|
rpc displayEditMenu(DisplayEditMenuRequest) returns (generic.Empty);
|
||||||
}
|
}
|
||||||
|
|
||||||
service BackendFrontendService {}
|
service BackendFrontendService {}
|
||||||
|
|
@ -51,3 +52,7 @@ message SetSchedulingStatesRequest {
|
||||||
message PlayAVTagsRequest {
|
message PlayAVTagsRequest {
|
||||||
repeated card_rendering.AVTag tags = 1;
|
repeated card_rendering.AVTag tags = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
message DisplayEditMenuRequest {
|
||||||
|
optional int64 cid = 1;
|
||||||
|
}
|
||||||
|
|
@ -28,10 +28,10 @@ import aqt
|
||||||
import aqt.main
|
import aqt.main
|
||||||
import aqt.operations
|
import aqt.operations
|
||||||
from anki import hooks
|
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.collection import OpChanges, OpChangesOnly, Progress, SearchNode
|
||||||
from anki.decks import UpdateDeckConfigs
|
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.v3 import SchedulingStatesWithContext, SetSchedulingStatesRequest
|
||||||
from anki.scheduler_pb2 import NextCardDataResponse
|
from anki.scheduler_pb2 import NextCardDataResponse
|
||||||
from anki.template import (
|
from anki.template import (
|
||||||
|
|
@ -698,6 +698,14 @@ def play_avtags():
|
||||||
play_tags(av_tags_to_native(req.tags))
|
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 = [
|
post_handler_list = [
|
||||||
congrats_info,
|
congrats_info,
|
||||||
get_deck_configs_for_update,
|
get_deck_configs_for_update,
|
||||||
|
|
@ -716,6 +724,7 @@ post_handler_list = [
|
||||||
save_custom_colours,
|
save_custom_colours,
|
||||||
next_card_data,
|
next_card_data,
|
||||||
play_avtags,
|
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 "./index.scss";
|
||||||
|
|
||||||
import AnswerButton from "./AnswerButton.svelte";
|
import AnswerButton from "./AnswerButton.svelte";
|
||||||
import { bridgeCommand } from "@tslib/bridgecommand";
|
|
||||||
import * as tr from "@generated/ftl";
|
import * as tr from "@generated/ftl";
|
||||||
import type { ReviewerState } from "../reviewer";
|
import type { ReviewerState } from "../reviewer";
|
||||||
import Remaining from "./Remaining.svelte";
|
import Remaining from "./Remaining.svelte";
|
||||||
import More from "./More.svelte";
|
import More from "./More.svelte";
|
||||||
|
import { displayEditMenu } from "@generated/backend";
|
||||||
|
|
||||||
export let state: ReviewerState;
|
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">
|
<div class="disappearing edit">
|
||||||
<button
|
<button
|
||||||
title={tr.actionsShortcutKey({ val: "E" })}
|
title={tr.actionsShortcutKey({ val: "E" })}
|
||||||
on:click={() => bridgeCommand("edit")}
|
on:click={() => displayEditMenu({ cid: state.currentCard?.card?.id })}
|
||||||
>
|
>
|
||||||
{tr.studyingEdit()}
|
{tr.studyingEdit()}
|
||||||
</button>
|
</button>
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue