Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom template and script, editor #3

Open
thangisme opened this issue Dec 24, 2021 · 2 comments
Open

Custom template and script, editor #3

thangisme opened this issue Dec 24, 2021 · 2 comments

Comments

@thangisme
Copy link

Do you plan to support card template like Anki? Also, Custom JS for any deck would be great.
I don't know if it is possible, I just suggest that you may take a look at TinyMCE,I'd love the ability to have a HTML editor like that.
Anyway, great work =)!

@lopul
Copy link
Owner

lopul commented Dec 25, 2021

Thanks for the encouragement :)

Currently every Deck can specify a (inline) <style> - the Style button is well hidden in the Preview screen (id="q-html" id="a-html" class="qa-html" / id="q-txt" id="a-txt" class="qa-txt").

My plan is having some kind of "default" (<style>) template (when a Deck is created [currently it's just blank {but has a definition in the ms.css}]), to have something the user can edit (the <style>) from... And maybe inherit the <style> in the Deck hierarchy... (And) I think to save (Export / Import) the <style> text to the .xml (optional) needs to be done too...

Edit some kind of <style> "template" in a separate place (from Cards and Decks), and later assign it to a Deck might be another way - but i haven't thought much on this (but is probably more intuitive to use, if it is done this way).

some kind of HTML editor (written in JavaScript) (like the one i currently type in) would be (very) nice - but it surely must be open source - and i'm not familiar with JavaScript - but TinyMCE is well documented and worth a look and could give some ideas... Currently i think this is something to experiment with...

@lopul
Copy link
Owner

lopul commented Jan 9, 2022

the latest version (no label) now has a simple HTML text editor (just text no formating):

(if a Card has HTML checked) the Preview screen now has a (enabled) check box 'Unlock' (which, if checked, sets 'contenteditable' to the Question and Answer <div>'s), which allows to edit the HTML text (of the Card).

after pressing the Edit button (Unlock needs to stay checked) the HTML is updated to the Card (the interaction is form based).

but 'contenteditable' is kind of tricky to work with (since the browser transforms the original HTML a bit) - for example "<b>bold<i>italic-bold</b>italic</i>" becomes "<b>bold<i>italic-bold</i></b><i>italic</i>" or a '>' character gets escaped (to &gt;), or a <tbody> tag gets inserted (in a <table>)... however it is nice that 'contenteditable' doesn't seem to touch the white-spaces (at least with the Firefox i tested it with).

currently it is just possible to do normal text editing, and the functionality needs some testing - but i hope to add: changing / adding <h1>, <p>, ..., <b> <em>, ..., <a ...> and <img ...>, and editing 'id' and 'class' attributes...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants