Skip to content

Wrap previewer type field syntax replacement in separate method#4563

Open
DaedalusIndigo wants to merge 4 commits intoankitects:mainfrom
DaedalusIndigo:patch-1
Open

Wrap previewer type field syntax replacement in separate method#4563
DaedalusIndigo wants to merge 4 commits intoankitects:mainfrom
DaedalusIndigo:patch-1

Conversation

@DaedalusIndigo
Copy link

It is currently difficult to modify how the previewer handles type-in-the-answer fields because the substitution is done as a very tiny line within the large _render_scheduled method. This PR adds a type_ans_preview_filter method that can easily be patched without affecting the entire renderer.

DaedalusIndigo and others added 2 commits February 17, 2026 14:57
Replace type field syntax as part of a separate function to allow easier patching by add-on developers.
Added DaedalusIndigo to the contributors list.
@DaedalusIndigo DaedalusIndigo changed the title Feat: Wrap previewer type field syntax replacement in separate method Wrap previewer type field syntax replacement in separate method Feb 17, 2026
self._timer.stop()
self._timer = None

def type_ans_preview_filter(self, txt: str, type: str = "q") -> str:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpick: let's pass the whole type string and improve the typing a bit by using Literal["question", "answer"]. You might also need to declare the same type for self._state in .open() to make mypy happy.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure! I was just trying to stay consistent with the native maybeTextInput method of the CardLayout class.

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

Successfully merging this pull request may close these issues.

2 participants