mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 22:12:21 -04:00
Save tags back to Python
This commit is contained in:
parent
375a96e263
commit
5575482e38
2 changed files with 15 additions and 2 deletions
|
@ -426,6 +426,14 @@ $editorToolbar.then(({{ toolbar }}) => toolbar.appendGroup({{
|
||||||
(_, highlightColor) = cmd.split(":", 1)
|
(_, highlightColor) = cmd.split(":", 1)
|
||||||
self.mw.pm.profile["lastHighlightColor"] = highlightColor
|
self.mw.pm.profile["lastHighlightColor"] = highlightColor
|
||||||
|
|
||||||
|
elif cmd.startswith("saveTags"):
|
||||||
|
(type, tagsJson) = cmd.split(":", 1)
|
||||||
|
self.note.tags = json.loads(tagsJson)
|
||||||
|
|
||||||
|
gui_hooks.editor_did_update_tags(self.note)
|
||||||
|
if not self.addMode:
|
||||||
|
self._save_current_note()
|
||||||
|
|
||||||
elif cmd in self._links:
|
elif cmd in self._links:
|
||||||
self._links[cmd](self)
|
self._links[cmd](self)
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
<script lang="typescript">
|
<script lang="typescript">
|
||||||
import { tick } from "svelte";
|
import { tick } from "svelte";
|
||||||
import { isApplePlatform } from "lib/platform";
|
import { isApplePlatform } from "lib/platform";
|
||||||
|
import { bridgeCommand } from "lib/bridgecommand";
|
||||||
import StickyBottom from "components/StickyBottom.svelte";
|
import StickyBottom from "components/StickyBottom.svelte";
|
||||||
import AddTagBadge from "./AddTagBadge.svelte";
|
import AddTagBadge from "./AddTagBadge.svelte";
|
||||||
import Tag from "./Tag.svelte";
|
import Tag from "./Tag.svelte";
|
||||||
|
@ -20,10 +21,14 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
|
|
||||||
export let tags: TagType[] = [];
|
export let tags: TagType[] = [];
|
||||||
|
|
||||||
export function resetTags(names: string[]) {
|
export function resetTags(names: string[]): void {
|
||||||
tags = names.map(attachId);
|
tags = names.map(attachId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function saveTags(): void {
|
||||||
|
bridgeCommand(`saveTags:${JSON.stringify(tags.map((tag) => tag.name))}`);
|
||||||
|
}
|
||||||
|
|
||||||
let active: number | null = null;
|
let active: number | null = null;
|
||||||
let activeAfterBlur: number | null = null;
|
let activeAfterBlur: number | null = null;
|
||||||
let activeName = "";
|
let activeName = "";
|
||||||
|
@ -236,12 +241,12 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
on:tagmoveprevious={() => moveToPreviousTag(index)}
|
on:tagmoveprevious={() => moveToPreviousTag(index)}
|
||||||
on:tagmovenext={() => moveToNextTag(index)}
|
on:tagmovenext={() => moveToNextTag(index)}
|
||||||
on:tagaccept={() => {
|
on:tagaccept={() => {
|
||||||
console.log("accept", tag, index, activeName);
|
|
||||||
deleteTagIfNotUnique(tag, index);
|
deleteTagIfNotUnique(tag, index);
|
||||||
decideNextActive();
|
decideNextActive();
|
||||||
if (tag) {
|
if (tag) {
|
||||||
updateWithTagName(tag);
|
updateWithTagName(tag);
|
||||||
}
|
}
|
||||||
|
saveTags();
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</TagAutocomplete>
|
</TagAutocomplete>
|
||||||
|
|
Loading…
Reference in a new issue