Giter VIP home page Giter VIP logo

anki-templates's People

Contributors

loganconnor44 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

anki-templates's Issues

phonetic inconsistency desktop/mobile

Hi Logan,

First of all, thank you for sharing your amazing work on templating.

I have an issue regarding pinyin display

On desktop, I got the following
image

And on mobile, (ankidroid, latest version), phonetic seems to be displayed in bopofomo in a weird way ?

image

audio template

I have seen your template they are look very nice.So I want to give it a try..
I want to add zhuyin and audio front side and meaning inside..
But the issue is front side..
It is possible to add inside instead of outside...Thanks alot
front

Screenshot from 2023-10-19 20-40-45

Can't get this working

Hey there,
ir really like your template and the style of the cards. They also have some nice features I'd like to use however I can not get this working...

My template is:

Frontside:

<script>if (!document.querySelector('#import-script')) {var script = document.createElement('script');script.setAttribute('id', 'import-script');script.setAttribute('type', 'module');script.setAttribute('src', 'https://cdn.jsdelivr.net/npm/[email protected]/dist/beautify-chinese-study/beautify-chinese-study.esm.js');document.body.appendChild(script);}</script>

<material-beautify-chinese-study simplified='{{text:simplified}}'
    traditional='{{text:traditional}}'
    numbered-pinyin='{{text:numberedPinyin}}'
    meaning='{{text:meaning}}'
    audio='{{sound}}'
    card-type='meaning'
    card-orientation='question'
    preferred-phonic='pinyin' />

Backside:

<script>if (!document.querySelector('#import-script')) {var script = document.createElement('script');script.setAttribute('id', 'import-script');script.setAttribute('type', 'module');script.setAttribute('src', 'https://cdn.jsdelivr.net/npm/[email protected]/dist/beautify-chinese-study/beautify-chinese-study.esm.js');document.body.appendChild(script);}</script>

<material-beautify-chinese-study simplified='{{text:simplified}}'
  traditional='{{text:traditional}}'
  numbered-pinyin='{{text:numberedPinyin}}'
  meaning='{{text:meaning}}'
  audio='{{sound}}'
  card-type='meaning'
  card-orientation='answer'
  preferred-phonic='pinyin' />

Style:

<style> /*desktop anki*/body {margin: 0;}/*ankidroid*/#content {margin: 0;}</style>

My fields are:

  • simplified: 你
  • traditional: 你 (dont learn traditional)
  • numberedPinyin: ni3
  • meaning: du (german)
  • sound: [sound:你.ogg]
  • stoke order: I'm saving a gif for each character

The card layout is working fine within the template editor but all actual cards (and their preview) remain black....
I'd really appriciate any help on this.

Awesome project!

Character Stroke Animation Duplicated - AnkiDroid Only

Issue

When using AnkiDroid the character stroke animation is duplicated.

Library Version

1.1.44

Client

Anki Droid

Template Code Snippets To Reproduce Issue

Front

<!--Styling may be placed in the Styling Anki tab - but for ease of use let's add it here only-->
<style>
	/*desktop anki*/
	body {
		margin: 0;
	}
	/*ankidroid*/
	#content {
		margin: 0;
	}
</style>

<script>
	// if the custom element material-beautify-chinese-study is not a known element
	//// manually create the html script to import the module so the browser has
	//// the necessary logic to create element
	if (!customElements.get('material-beautify-chinese-study')) {
		console.log('Custom element does not exist - Creating script to pull it in');
		var script = document.createElement('script');
		script.setAttribute('id', 'import-script');
		script.setAttribute('type', 'module');
		script.setAttribute('src', 'https://cdn.jsdelivr.net/npm/beautify-chinese-study/dist/beautify-chinese-study/beautify-chinese-study.esm.js');
		document.body.appendChild(script);
	} else {
		console.log('Custom element exists.');
	}

	// locate the custom element material-beautify-chinese-study on the DOM
	//// if it has data - remove everything
	var beautify = document.querySelector('material-beautify-chinese-study');
	if (beautify !== null) {
		beautify.remove();
	}
	var beautify = document.createElement('material-beautify-chinese-study');
	beautify.setAttribute('id', 'beautify');
	beautify.setAttribute('simplified', '{{text:Simplified}}');
	beautify.setAttribute('traditional', '{{text:Traditional}}');
	beautify.setAttribute('simplified-sentence', '{{text:SentenceSimplified}}');
	beautify.setAttribute('traditional-sentence', '{{text:SentenceTraditional}}');
	// double quotes intentional do to the value containing a single quote
	beautify.setAttribute('meaning', "{{text:Meaning}}");
	beautify.setAttribute('card-type', 'writing');
	beautify.setAttribute('card-orientation', 'question');
	beautify.setAttribute('preferred-phonic', 'zhuyin');
	// add the element to the DOM body
	document.body.appendChild(beautify);
</script>

<!--Always add audio and keep it invisible-->
<div style="display:none;">{{Audio}}{{SentenceAudio}}</div>

Back

<!--Styling may be placed in the Styling Anki tab - but for ease of use let's add it here only-->
<style>
	/*desktop anki*/
	body {
		margin: 0;
	}
	/*ankidroid*/
	#content {
		margin: 0;
	}
</style>

<script>
	// if the custom element material-beautify-chinese-study is not a known element
	//// manually create the html script to import the module so the browser has
	//// the necessary logic to create element
	if (!customElements.get('material-beautify-chinese-study')) {
		var script = document.createElement('script');
		script.setAttribute('id', 'import-script');
		script.setAttribute('type', 'module');
		script.setAttribute('src', 'https://cdn.jsdelivr.net/npm/beautify-chinese-study/dist/beautify-chinese-study/beautify-chinese-study.esm.js');
		document.body.appendChild(script);
	}

	// since we are on the back of the card the custom element from the front of the card
	//// may have been retained - in instances of AnkiDroid a new webview is created and
	//// the element will need to be recreated from scratch
	var beautify = document.querySelector('#beautify');
	if (!beautify) {
		// probably executing because on AnkiDroid
		// recreating element from scratch
		
		var beautify = document.createElement('material-beautify-chinese-study');
		beautify.setAttribute('id', 'beautify');
		beautify.setAttribute('simplified', '{{text:Simplified}}');
		beautify.setAttribute('writing', '{{text:Simplified}}');
		beautify.setAttribute('simplified-sentence', '{{text:SentenceSimplified}}');
		beautify.setAttribute('traditional-sentence', '{{text:SentenceTraditional}}');
		// double quotes intentional do to the value containing a single quote
		beautify.setAttribute('meaning', "{{text:Meaning}}");
		beautify.setAttribute('card-type', 'writing');
		beautify.setAttribute('card-orientation', 'answer');
		beautify.setAttribute('preferred-phonic', 'zhuyin');
		document.body.appendChild(beautify);
	} else {
		// element already exist
		// redefine the card type just for safe keeping
		// redefine the card orientation to display the answer logic
		beautify.setAttribute('card-type', 'writing');
		beautify.setAttribute('card-orientation', 'answer');
	}
</script>

<!--Always add audio and keep it invisible-->
<div style="display:none;">{{Audio}}{{SentenceAudio}}</div>

Update Package version

It seems that commit 10a4e23 which includes major relabeling is not yet used since the package is still on b80e476 version 1.1.44 and npm isn't updated yet.

Brief Flash Of Unstyled DOM - AnkiDroid Only

Issue

When using AnkiDroid the application flashes for a moment before each card (front and back) renders.

Library Version

1.1.48

Client

Anki Droid

Template Code Snippets To Reproduce Issue

Found Here

Possible Cause

AnkiDroid handles the WebView different than Desktop Anki. It destroys and recreates it between each and every front and back card.

Work Around

In Anki's styling section, I've added a completely black background so this will be rendered first. This does not prevent the flash of DOM, but it makes the flash less abrupt compared to a white background.

Long Term Solution

Storing or caching the web component, similar to how PWA operate. Maybe adding a service worker via StencilJs would be appropriate.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.