precommit
This commit is contained in:
parent
665179309e
commit
a18a5b021d
@ -670,10 +670,10 @@ class ShikiHighLevelCodeBlock(ShikiCodeBlock):
|
||||
show_line_numbers: Var[bool]
|
||||
|
||||
# Whether a copy button should appear.
|
||||
can_copy: Var[bool] = False
|
||||
can_copy: Var[bool] = Var.create(False)
|
||||
|
||||
# copy_button: A custom copy button to override the default one.
|
||||
copy_button: Var[Optional[Union[Component | bool]]] = None
|
||||
copy_button: Var[Optional[Union[Component, bool]]] = Var.create(None)
|
||||
|
||||
@classmethod
|
||||
def create(
|
||||
|
@ -309,6 +309,7 @@ LiteralCodeTheme = Literal[
|
||||
"nord",
|
||||
"one-dark-pro",
|
||||
"one-light",
|
||||
"plain",
|
||||
"plastic",
|
||||
"poimandres",
|
||||
"red",
|
||||
@ -815,6 +816,7 @@ class ShikiCodeBlock(Component):
|
||||
"nord",
|
||||
"one-dark-pro",
|
||||
"one-light",
|
||||
"plain",
|
||||
"plastic",
|
||||
"poimandres",
|
||||
"red",
|
||||
@ -869,6 +871,7 @@ class ShikiCodeBlock(Component):
|
||||
"nord",
|
||||
"one-dark-pro",
|
||||
"one-light",
|
||||
"plain",
|
||||
"plastic",
|
||||
"poimandres",
|
||||
"red",
|
||||
@ -981,10 +984,12 @@ class ShikiHighLevelCodeBlock(ShikiCodeBlock):
|
||||
def create( # type: ignore
|
||||
cls,
|
||||
*children,
|
||||
can_copy: Optional[bool] = False,
|
||||
copy_button: Optional[Union[Component, bool]] = None,
|
||||
use_transformers: Optional[Union[Var[bool], bool]] = None,
|
||||
show_line_numbers: Optional[Union[Var[bool], bool]] = None,
|
||||
can_copy: Optional[Union[Var[bool], bool]] = None,
|
||||
copy_button: Optional[
|
||||
Union[Component, Var[Optional[Union[Component, bool]]], bool]
|
||||
] = None,
|
||||
language: Optional[
|
||||
Union[
|
||||
Literal[
|
||||
@ -1456,6 +1461,7 @@ class ShikiHighLevelCodeBlock(ShikiCodeBlock):
|
||||
"nord",
|
||||
"one-dark-pro",
|
||||
"one-light",
|
||||
"plain",
|
||||
"plastic",
|
||||
"poimandres",
|
||||
"red",
|
||||
@ -1510,6 +1516,7 @@ class ShikiHighLevelCodeBlock(ShikiCodeBlock):
|
||||
"nord",
|
||||
"one-dark-pro",
|
||||
"one-light",
|
||||
"plain",
|
||||
"plastic",
|
||||
"poimandres",
|
||||
"red",
|
||||
@ -1592,10 +1599,10 @@ class ShikiHighLevelCodeBlock(ShikiCodeBlock):
|
||||
|
||||
Args:
|
||||
*children: The children of the component.
|
||||
can_copy: Whether a copy button should appear.
|
||||
copy_button: A custom copy button to override the default one.
|
||||
use_transformers: If this is enabled, the default transformers(shikijs transformer) will be used.
|
||||
show_line_numbers: If this is enabled line numbers will be shown next to the code block.
|
||||
can_copy: Whether a copy button should appear.
|
||||
copy_button: copy_button: A custom copy button to override the default one.
|
||||
language: The language to use.
|
||||
theme: The theme to use ("light" or "dark").
|
||||
themes: The set of themes to use for different modes.
|
||||
@ -1625,10 +1632,12 @@ class CodeblockNamespace(ComponentNamespace):
|
||||
@staticmethod
|
||||
def __call__(
|
||||
*children,
|
||||
can_copy: Optional[bool] = False,
|
||||
copy_button: Optional[Union[Component, bool]] = None,
|
||||
use_transformers: Optional[Union[Var[bool], bool]] = None,
|
||||
show_line_numbers: Optional[Union[Var[bool], bool]] = None,
|
||||
can_copy: Optional[Union[Var[bool], bool]] = None,
|
||||
copy_button: Optional[
|
||||
Union[Component, Var[Optional[Union[Component, bool]]], bool]
|
||||
] = None,
|
||||
language: Optional[
|
||||
Union[
|
||||
Literal[
|
||||
@ -2100,6 +2109,7 @@ class CodeblockNamespace(ComponentNamespace):
|
||||
"nord",
|
||||
"one-dark-pro",
|
||||
"one-light",
|
||||
"plain",
|
||||
"plastic",
|
||||
"poimandres",
|
||||
"red",
|
||||
@ -2154,6 +2164,7 @@ class CodeblockNamespace(ComponentNamespace):
|
||||
"nord",
|
||||
"one-dark-pro",
|
||||
"one-light",
|
||||
"plain",
|
||||
"plastic",
|
||||
"poimandres",
|
||||
"red",
|
||||
@ -2236,10 +2247,10 @@ class CodeblockNamespace(ComponentNamespace):
|
||||
|
||||
Args:
|
||||
*children: The children of the component.
|
||||
can_copy: Whether a copy button should appear.
|
||||
copy_button: A custom copy button to override the default one.
|
||||
use_transformers: If this is enabled, the default transformers(shikijs transformer) will be used.
|
||||
show_line_numbers: If this is enabled line numbers will be shown next to the code block.
|
||||
can_copy: Whether a copy button should appear.
|
||||
copy_button: copy_button: A custom copy button to override the default one.
|
||||
language: The language to use.
|
||||
theme: The theme to use ("light" or "dark").
|
||||
themes: The set of themes to use for different modes.
|
||||
|
@ -20,9 +20,8 @@ from reflex.components.tags.tag import Tag
|
||||
from reflex.utils import types
|
||||
from reflex.utils.imports import ImportDict, ImportVar
|
||||
from reflex.vars.base import LiteralVar, Var
|
||||
from reflex.vars.number import ternary_operation
|
||||
from reflex.vars.function import ARRAY_ISARRAY
|
||||
|
||||
from reflex.vars.number import ternary_operation
|
||||
|
||||
# Special vars used in the component map.
|
||||
_CHILDREN = Var(_js_expr="children", _var_type=str)
|
||||
@ -202,7 +201,13 @@ class Markdown(Component):
|
||||
raise ValueError(f"No markdown component found for tag: {tag}.")
|
||||
|
||||
special_props = [_PROPS_IN_TAG]
|
||||
children = [_CHILDREN if not tag == "codeblock" else ternary_operation(ARRAY_ISARRAY.call(_CHILDREN), _CHILDREN.to(LiteralVar)[0], _CHILDREN).to(str)]
|
||||
children = [
|
||||
_CHILDREN
|
||||
if tag != "codeblock"
|
||||
else ternary_operation(
|
||||
ARRAY_ISARRAY.call(_CHILDREN), _CHILDREN.to(list)[0], _CHILDREN
|
||||
).to(str)
|
||||
]
|
||||
|
||||
# For certain tags, the props from the markdown renderer are not actually valid for the component.
|
||||
if tag in NO_PROPS_TAGS:
|
||||
|
Loading…
Reference in New Issue
Block a user