Giter Site home page Giter Site logo

anki__editor__apply__font_color__background_color__custom_class__custom_style's People

Contributors

hgiesel avatar ijgnd avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

anki__editor__apply__font_color__background_color__custom_class__custom_style's Issues

Feature Request: Placeholder for text under selection

In text wrapper, a placeholder for text under selection would be nice

For eg: "Hello there %s, How are you today %s" when applied while having "Robert" under selection, you get Hello there Robert, How are you today Robert

2.1.41+ night-mode css not applied in editor

This add-on allows to define alternative styling for the night mode. So css like this is set by this add-on while Anki is in night mode

.myclassname{
background-color: #... !important;
}

.nightMode .myclassname{
background-color: #... !important;
}

The css for the nightmode works in the reviewer and previewer but since 2.1.41 no longer in the editor.

I tested with the binaries for .41 and .42 for linux from apps.ankiweb.net with the most recent version of the "custom styles" add-on from ankiweb (from 2021-03-03). During this test I had no other add-ons installed.

I have no idea what to do at the moment. I hope that you'll have time to look into this.

Thanks.

少了文件?

############## forms 里面没有settings_main_widgets ##########
from .forms import settings_main_widgets
from .addEntry import AddEntry
from .utils import gui_dialog

class MainConfDialog(QDialog):
def init(self, c):
parent = mw.app.activeWindow()
QDialog.init(self, parent)
self.config = c
self.bo = settings_main_widgets.Ui_Dialog()

broken in 2.1.50 (Attribute error, ...)

Error
An error occurred. Please start Anki while holding down the shift key, which will temporarily disable the add-ons you have installed.
If the issue only occurs when add-ons are enabled, please use the Tools > Add-ons menu item to disable some add-ons and restart Anki, repeating until you discover the add-on that is causing the problem.
When you've discovered the add-on that is causing the problem, please report the issue on the add-on support site.
Debug info:
Anki 2.1.50 (81cc5a09) Python 3.10.1 Qt 5.15.2 PyQt 5.15.6
Platform: Linux
Flags: frz=False ao=True sv=2
Add-ons, last update check: 2022-01-20 21:36:13
Add-ons possibly involved: ⁨editor: apply font color, background color, custom class, custom style⁩

Caught exception:
Traceback (most recent call last):
File "/usr/lib/python3.10/site-packages/aqt/main.py", line 336, in onOpenProfile
self.loadProfile(self.profileDiag.closeWithoutQuitting)
File "/usr/lib/python3.10/site-packages/aqt/main.py", line 462, in loadProfile
gui_hooks.profile_did_open()
File "/usr/lib/python3.10/site-packages/aqt/hooks_gen.py", line 3077, in call
anki.hooks.runHook("profileLoaded")
File "/usr/lib/python3.10/site-packages/anki/hooks.py", line 34, in runHook
func(*args)
File "/home/grim/.local/share/Anki2/addons21/1899278645/color_style_class_buttons.py", line 230, in prepareEditorStylesheet
editor._html = editor_style + editor._html
AttributeError: module 'aqt.editor' has no attribute '_html'

shorten the red box?

Is there any way that one can make the red box smaller and not over the whole flashcard width?

Text Wrapping function malfunctions when wrapping string contains quotation marks.

I was migrating to this addon from the "Wrapper meta-addon" and "editor wrap selected text with custom HTML" addons, and I encountered a possible bug when I tried to make a Text Wrapping function with the Wrap Before string being <div style="font-size: 0px;">{{c1::. and After string being }}</div>.

The addon works as expected when I use the shortcut, but if I switch on the "show extra button" option, it displays like so:
Custom Wrapper bug report


An alternate form of the error may appear too:

Steps to reproduce:

  1. Make a wrapping function as described above
  2. Open the config of the addon
  3. Without changing anything, close it using the close button at the top corner, (not the OK button)
  4. Open the add window
  5. Leads to this, a normal looking button in the Add Window:

Custom Wrapper bug report

Upon clicking the button or using the

The error message is:

Error 
An error occurred. Please start Anki while holding down the shift key, which will temporarily disable the add-ons you have installed. 
If the issue only occurs when add-ons are enabled, please use the Tools>Add-ons menu item to disable some add-ons and restart Anki, repeat until you discover the add-on that is causing the problem. 
When you've discovered the add-on that is causing the problem, please report the issue on the add-ons section of our support site. 
Debug info:
Anki 2.1.33 (3f403040) Python 3.8.0 Qt 5.14.1 PyQt 5.14.1
Platform: Windows 10
Flags: frz=True ao=True sv=2
Add-ons, last update check: 2021-04-17 00:42:28

Caught exception:
Traceback (most recent call last):
  File "aqt\webview.py", line 37, in cmd
  File "aqt\webview.py", line 123, in _onCmd
  File "aqt\webview.py", line 547, in _onBridgeCmd
  File "<D:\Programs\Anki\decorator.pyc:decorator-gen-64>", line 2, in onBridgeCmd
  File "anki\hooks.py", line 638, in decorator_wrapper
  File "anki\hooks.py", line 635, in repl
  File "D:\Data Storage\AnkiData\addons21\516643804\main.py", line 135, in onBridge
    return _old(self, str)
  File "aqt\editor.py", line 416, in onBridgeCmd
  File "D:\Data Storage\AnkiData\addons21\1899278645\editor\shortcuts_buttons.py", line 49, in <lambda>
    function = lambda e=editor, c=e["Setting"]: func(e, c)
  File "D:\Data Storage\AnkiData\addons21\1899278645\editor\editor_apply_categories.py", line 27, in my_wrap_helper
    before, after = beforeAfter.split(unique_string)
ValueError: not enough values to unpack (expected 2, got 1)


The wrapping function works well with strings that do not contain quotation marks.
I can get around the issue by simply not having a gui button in the add dialog and relying on the shortcut, so it's not really an inconvenience for now, but thought it better to inform you about it anyway.

Cloze deletion does not preserve the style

Generated cloze deletion will be excluded from the styles, as you can see from the image and code below.
2019-08-29_21-55-53
2019-08-29_21-56-08

<font color="#00aa00">This is&nbsp;</font>{{c1::green}}<font color="#00aa00">.</font>

Overwrites "Preferences" action on mac

In the newest version (that's also on AnkiWeb), when I try to open the Anki Preferences, I instead get the config window for this addon.

I cannot say, whether the same happens on other platforms though.

formatting is applied to more than selection

I attached a zip file which contains a video of me screen recording the bug and a screenshot of my configs in case you need to see it.

Essentially the bug happens when I try highlighting text and then use the hotkey that I preset for a certain text styling and what happens is that it does the styling on other non-highlighted text which is very annoying!

This use to never happen at all. But I believe after one of these recent updates the bug appeared!

Thank you again for making such an awesome add on! I love using it! I also posted this on the anki thread forum/help thing.

Screen Shot 2020-07-09 at 12 49 48 PM

Bug Evidence.zip

Feature requests: Custom HTML wrapping

Would it be difficult to implement a feature so that you could wrap text with customised HTML.

one interesting use would be quickly making expandable lists:

<details><summary>Expand/collapse me!</summary>sample text to be wrapped</details>

to give something like this

Expand/collapse me!sample text to be wrapped

I thought just standard text wrapping should work but when I try it, it removes the text between </summary> and </details>

Passing over ownership of the Ankiweb listing

Hi,
we've already talked about this some time ago, are you still up for it?
I see the need for several fixes, and I don't want to force the whole uploading to you every single time, especially if I introduce stupid subtle bugs.

If yes, I would post the request on the Anki forum itself.

Changing font family?

So I tried to change the font-style but unfortunately I didn't find anything in the styling sections in which I can change that. And adding stuff like "font-style" oder family in the .card section does not change anything.

What am I doing wrong?

copy styles

i can't use this addon to copy styles. when i paste the style text to another anki field.it doesn't woks
屏幕快照 2019-07-09 下午4 37 03

clear formatting: It doesn't work

MacOS
Anki 2.1.49

Thank you for your addon, it's very easy to add format。
After installing the addon, I formatted the text but couldn't clean it up.
When I pressed F2, I clicked on the option Clear More Formatting but it didn't work.
Pressing Alt + R doesn't work either.
I tried to disable all addons but this one, but it still didn't work

Improvement in the backcolor category

I want to leave a suggestion, which in my view will be quite simple and useful.

  • Problem
    Sometimes I want to use a highlight, for example yellow, that is the same shade in both normal and night mode. That's because, on the desktop I use the clear mode and on the ankidroid I use the nightmode.
    The problem is that the lyrics are practically unintelligible:
    Screenshot_20201116-221647__01
    1

I have many options to solve the problem, such as fixing the letter in the color I want. But this is not practical.

  • Suggestion

You could create an option to add a different color to the nightmode, along with the backcolor.
I thought on two occasions:

  1. place a checkbox to activate: color: initial;. This will set the default color in light mode, even in night mode. Preventing the color inversion of the letter.
  2. put color select scheme, as already exists in the addon. If the person wants a different color in the text.

I currently use the following configuration:
Background-color: yellow; color: initial; display: inline;
with the following result:
Screenshot_20201116-223013__01

thanks.

The name of this addon

Something that bothered me for sometime, is the name of this add-on.
I wonder how you think about renaming it a little bit succinctly.

For example take the beginning, and the end, and go with "Editor Apply Custom Styles".
This way "custom styles" can include all the other things mentioned (font color, custom class, etc.).

I like descriptive names, but to this day my brain refuses to memorize the name of this add-on ^^;

Media references are not refreshed upon restart

I recently noticed a bug when updating your _editor_button_styles.css. It seems like Anki doesn't recognize that the file was updated, and won't upload it to AnkiWeb, which means the file won't be updated on AnkiMobile (and possible AnkiDroid).

With 2.0 this behavior could be fixed with an app like this: https://ankiweb.net/shared/info/162278717. However it doesn't work on 2.1. I'm sure this could be replicated in 2.1.

some shortcuts no longer work in 2.1.30 that worked in 2.1.26

I tested the default shorcuts with the binary for 2.1.30 from apps.ankiweb.net in Linux without any other add-ons.

The following default shortcuts work in 2.1.26 but not in 2.1.30 for me:

  • alt+q
  • alt+w
  • shift+alt+f
  • shift+alt+5

I have no idea these don't work anymore, as far as I see there were no changes in the Anki source code (i.e. in editor.py and addcards.py) that could have this effect.

Add option to disable the dialog asking to auto update templates

I'd like to have an option to disable the dialog that asks if I want to update all my templates.

I understand that it is required for the add on to fully work, but I don't want to use it on all my note types, so I'd rather add the import manually to the note types where I need it.

In case you don't want such an option because people might activate it without knowing what it does, is there an easy (preferably permanent) way to disable the dialog in the source files?

Edits I made are not transferring to new devices

I recently got a new computer and had to re-download anki as well as the add-on. In my old computer I had used the add-on extensively and made so many edits on cards using the shortcuts I made. However, I noticed immediately that since I got this new laptop that all the edits are gone (about ~5 to 10% are still there but very rarely). I downloaded everything on the new computer and then synced it. I then synced it to my phone and noticed they were also gone there as well. Is there any way to fix this?

If it helps-
The old computer (which is currently getting fixed) may have had an older version of Anki. I believe it was 2.1.31 and it was up to date as of 9/9/20 for the add-on updates. Could this be why? That's the only reason I see it failing. Of course, since I got this new computer this version is 2.1.33.

Selection of multiple lines not recognised when disabling entries in options

I've just downloaded this add on and noticed this little bug when I wanted to disable the default styles in the options window. When multiple lines are selected it only disables the entry that was clicked on last, e. g. when I select lines 3 to 5 by first clicking on 3 and then on 5 (with Shift hold) it only disables line 5, if I select them the other way round it only disables line 3.

No big issue but I thought I mention it.

broken in 2.1.41

I can no longer apply classes to selected text: the html source code of the field is unchanged.

I tried without any other add-ons, the custom styles version I used was the latest commit from this repo. It worked in 2.1.40. I think the problems is the javascript code used in the add-on.

@hgiesel: Since you know js and made some changes to the editor in 2.1.41 maybe you could have a look at this? Thanks.

Bug - new Forecolor (inline) Backcolor (inline)

Error
An error occurred. Please start Anki while holding down the shift key, which will temporarily disable the add-ons you have installed.
If the issue only occurs when add-ons are enabled, please use the Tools > Add-ons menu item to disable some add-ons and restart Anki, repeating until you discover the add-on that is causing the problem.
When you've discovered the add-on that is causing the problem, please report the issue on the add-on support site.
Debug info:
Anki 2.1.26 (70784154) Python 3.8.0 Qt 5.14.1 PyQt 5.14.1
Platform: Windows 7
Flags: frz=True ao=True sv=2
Add-ons, last update check: 2020-06-09 23:00:34

Caught exception:
Traceback (most recent call last):
File "C:\Users\Ronil Patel\AppData\Roaming\Anki2\addons21\1899278645\confdialog_MAIN.py", line 118, in accept
if a.exec_():
AttributeError: 'NoneType' object has no attribute 'exec_'

image

Simplifying the context menu - just an idea.

image

Love the add-on. This is just an idea for anyone who may want to have a simpler context menu.

contextmenu.py

from aqt.gui_hooks import editor_will_show_context_menu
from aqt.qt import *
from aqt.editor import Editor

from ..config_var import getconfig
from ..colors import hex_to_rgb_string

from .rangy_helpers import classes_addon_rangy_remove_all
from .apply_categories import apply_categories


def my_highlight_helper(view, category, setting):
    func = apply_categories[category]
    func(view.editor, setting)

def create_menu_entry(view, e, menu):
    textInMenu = e["Text_in_menu"]
    cat = e["Category"]
    se = e.get("Setting", e.get("Category", False))
    x = menu.addAction(textInMenu)
    x.triggered.connect(lambda _, a=cat, b=se: my_highlight_helper(view, a, b))  # ???
    return x

def setup_contextmenu(view, menu):
    config = getconfig()

    if config.get("v2_show_in_contextmenu", False):
        return

    menu.addSeparator()

    a = menu.addAction("Clear formatting")
    a.triggered.connect(lambda _: classes_addon_rangy_remove_all(view.editor))

    for row in config['v3']:
        if row.get('Show_in_menu', True):
            menu.addAction(create_menu_entry(view, row, menu))

    menu.addSeparator()

hotkeys no longer working

Hello, I have lots of hotkeys set up for this add-on, like alt+d or alt+r. They no longer work, probably since I updated to 2.1.30 (not sure).

I tried different combinations and can't get it to work. The multi-button hotkey still works though.

Platform: MacOS

Activating "class (other)" wrap triggers exception

Trying to activate a wrap of type "class (other)" triggers an exception.
This is on the version from 2020-05-14.

Caught exception:
Traceback (most recent call last):
  File "/Users/hgiesel/.local/share/AnkiDev/addons21/1899278645/menu.py", line 126, in <lambda>
    x.triggered.connect(lambda _, a=cat, b=se: my_highlight_helper(editor, a, b))
  File "/Users/hgiesel/.local/share/AnkiDev/addons21/1899278645/menu.py", line 35, in my_highlight_helper
    func(editor, setting)
  File "/Users/hgiesel/.local/share/AnkiDev/addons21/1899278645/editor_apply_styling_functions.py", line 115, in my_apply_span_class
    if e["Category"] == "class (other)" and e["Setting"] == _class and e["surround_with_div_tag"]:
KeyError: 'surround_with_div_tag'

Bug - attempt to change hotkey for font size

I received the following bug when trying to change the hotkey for font size to 130%

Debug info:
Anki 2.1.26 (70784154) Python 3.8.0 Qt 5.14.1 PyQt 5.14.1
Platform: Windows 7
Flags: frz=True ao=True sv=2
Add-ons, last update check: 2020-05-30 04:08:38

Caught exception:
Traceback (most recent call last):
File "C:\Users\Ronil Patel\AppData\Roaming\Anki2\addons21\1899278645\confdialog_Fontsize.py", line 62, in accept
"Text_in_menu_styling": self.return_font_size(),
File "C:\Users\Ronil Patel\AppData\Roaming\Anki2\addons21\1899278645\confdialog_Fontsize.py", line 53, in return_font_size
return font.rstrip(";").lstrip("font-size:")
AttributeError: 'tuple' object has no attribute 'rstrip'

Thanks for your awesome addons!And I have a problem

Snipaste_2019-04-19_21-17-21
Snipaste_2019-04-19_21-20-29
The class not working.Background and foreground works well.
My system is win10 64bit,and anki 2.0.52.
Thanks for your awesome addons,again!I have try multime colored addons,yours is the best for time saving.

Add support for wrapping with text

I'm an avid user of your addon, and wondered whether you would add support for wrapping a selection with raw text, rather than a tag. An example:

Capital of Italy is Rome

You select the text "Rome". Then you press a shortcut defined in the Config dialog, and you end up with:

Capital of Italy is {{c1::Rome}}

Of course this would just recreate the cloze shortcut, however the difference would be that it is configurable.

My use case is specifically my add-on Set Randomizer. I'm sure users would find other users.

I've been thinking about implementing it on my own for some time now, but it kinda exceeds the scope that I originally envisioned, and I think it would much better fit into this add-on.

I would write a pull request if it's okay with you.

Rangy.js does not work at all anymore

I noticed this already in a previous Anki version, even though I couldn't exactly tell which one.
In the Editor webview, it says:

Failed to load resource rangy-core.js: the server responded with a status of 403 (FORBIDDEN)

I will try to look at this myself, and make some general improvement PRs at the same time.

"!important" tag in the CSS file

I don't want to bother you with something unimportant for most people, so I consider this a very humble suggestion.

In this add-on, as coded in the file css_for_webviews.py, all the css colors are added with the "!important" tag. Managing various styles, and especially in face of the need of different settings for nightmode colors, sometimes this "!important" tag, that fundamentally changes the way that page's CSS is processed, prevents me from, for example, setting in another CSS file (or styling section of the card) that the "fg_red" class (red font) will not be red when it is inserted in a blue box (div section with an specific class applied), for example. This may be annoying sometimes, and I didn't realize yet the need for this "!important" being added in the CSS file. Personally, I always alter that css_for_webviews.py, removing the 5 "!important" that there are in that file. And I would suggest you, if it is not that relevant, not to add this "!important".

2.1.41+ wrong colors in editor and in actual card

Noticed it after 2.1.41

Have only tried this on night mode.
Attached are my settings for the two color codes and two pictures on how should look like (google search).
I also reproduced the problem in an attached video.
Green Color on Settings
Pink Color on Settings
Pink
Green

Creating.card.mov

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.