mirror of
https://github.com/ankitects/anki.git
synced 2026-01-09 03:53:55 -05:00
Merge branch 'main' into ci-cargo-deny
This commit is contained in:
commit
7a997a9a7c
2 changed files with 11 additions and 15 deletions
|
|
@ -4,7 +4,12 @@
|
||||||
import { getRange, getSelection } from "./cross-browser";
|
import { getRange, getSelection } from "./cross-browser";
|
||||||
|
|
||||||
function wrappedExceptForWhitespace(text: string, front: string, back: string): string {
|
function wrappedExceptForWhitespace(text: string, front: string, back: string): string {
|
||||||
const match = text.match(/^(\s*)([^]*?)(\s*)$/)!;
|
const normalizedText = text
|
||||||
|
.replace(/ /g, " ")
|
||||||
|
.replace(/ /g, " ")
|
||||||
|
.replace(/\u00A0/g, " ");
|
||||||
|
|
||||||
|
const match = normalizedText.match(/^(\s*)([^]*?)(\s*)$/)!;
|
||||||
return match[1] + front + match[2] + back + match[3];
|
return match[1] + front + match[2] + back + match[3];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,9 @@ export const addOrUpdateNote = async function(
|
||||||
backExtra,
|
backExtra,
|
||||||
tags,
|
tags,
|
||||||
});
|
});
|
||||||
showResult(mode.noteId, result, noteCount);
|
if (result.note) {
|
||||||
|
showResult(mode.noteId, result, noteCount);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
const result = await addImageOcclusionNote({
|
const result = await addImageOcclusionNote({
|
||||||
// IOCloningMode is not used on mobile
|
// IOCloningMode is not used on mobile
|
||||||
|
|
@ -55,23 +57,12 @@ export const addOrUpdateNote = async function(
|
||||||
// show toast message
|
// show toast message
|
||||||
const showResult = (noteId: number | null, result: OpChanges, count: number) => {
|
const showResult = (noteId: number | null, result: OpChanges, count: number) => {
|
||||||
const props = $state({
|
const props = $state({
|
||||||
message: "",
|
message: noteId ? tr.browsingCardsUpdated({ count: count }) : tr.importingCardsAdded({ count: count }),
|
||||||
type: "error" as "error" | "success",
|
type: "success" as "error" | "success",
|
||||||
showToast: true,
|
showToast: true,
|
||||||
});
|
});
|
||||||
mount(Toast, {
|
mount(Toast, {
|
||||||
target: document.body,
|
target: document.body,
|
||||||
props,
|
props,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (result.note) {
|
|
||||||
const msg = noteId ? tr.browsingCardsUpdated({ count: count }) : tr.importingCardsAdded({ count: count });
|
|
||||||
props.message = msg;
|
|
||||||
props.type = "success";
|
|
||||||
props.showToast = true;
|
|
||||||
} else {
|
|
||||||
const msg = tr.notetypesErrorGeneratingCloze();
|
|
||||||
props.message = msg;
|
|
||||||
props.showToast = true;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue