-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat(all): embed options * docs: Create embed-options.md
- Loading branch information
Showing
10 changed files
with
132 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'anki-templates': minor | ||
--- | ||
|
||
feat(all): embed options (嵌入选项) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# Embedding Options in Templates | ||
|
||
Since Anki does not provide the ability to store data in templates, there are some issues with user preference settings in templates: | ||
- Cannot sync across multiple devices | ||
- Preferences may be lost when restarting Anki on some clients | ||
|
||
To resolve these issues, you need to paste the formatted template settings below into the template code. This process involves two steps: | ||
1. Open the card template settings in Anki. The method to access this varies by platform, so please refer to the official user documentation. | ||
2. Find the "Front Template" of this template and paste the formatted template configuration you see on the settings page into the corresponding location. Below is an example image from the Mac version of Anki, other versions may display differently: | ||
<img width="1033" alt="图片" src="https://github.com/user-attachments/assets/e59139c1-2b22-422f-8eaa-d7bb528aa472" /> | ||
|
||
These modifications may be overwritten when upgrading the template, so please backup the formatted template settings before upgrading. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,10 @@ | ||
import OptionsPage from './options'; | ||
import SettingsPage from './settings'; | ||
import ToolsPage from './tools'; | ||
import { Page, PageMap } from '@/hooks/use-page'; | ||
|
||
export const DEFAULT_PAGES: PageMap = { | ||
[Page.Settings]: SettingsPage, | ||
[Page.Tools]: ToolsPage, | ||
[Page.Options]: OptionsPage, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { Block } from '@/components/block'; | ||
import { useNavigate, Page } from '@/hooks/use-page'; | ||
import * as t from 'at/i18n'; | ||
import { id } from 'at/options'; | ||
import { useMemo } from 'react'; | ||
|
||
export default () => { | ||
const navigate = useNavigate(); | ||
const options = useMemo(() => { | ||
const options = Object.fromEntries( | ||
Object.keys(localStorage) | ||
.filter( | ||
(key) => | ||
(key.startsWith('at:_global:') || key.startsWith(`at:${id}:`)) && | ||
!!localStorage.getItem(key), | ||
) | ||
.map((key) => [key, localStorage.getItem(key)]), | ||
); | ||
return JSON.stringify(options, undefined, 2); | ||
}, []); | ||
|
||
return ( | ||
<Block | ||
name={t.optionsPage} | ||
action={t.back} | ||
onAction={() => navigate(Page.Settings)} | ||
> | ||
<div className="prose prose-sm prose-neutral dark:prose-invert"> | ||
<p | ||
dangerouslySetInnerHTML={{ | ||
__html: t.optionsHelp, | ||
}} | ||
/> | ||
<pre>{options}</pre> | ||
</div> | ||
</Block> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters