Skip to content

Commit ff5e708

Browse files
authored
Merge pull request #3 from Lendemor/release/v0_0_2
update code for compat with 0.7.0
2 parents 29835b8 + ab37696 commit ff5e708

File tree

4 files changed

+18
-11
lines changed

4 files changed

+18
-11
lines changed

custom_components/reflex_monaco/monaco.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class MonacoComponent(rx.Component):
1717
theme: rx.Var[str] = rx.color_mode_cond("light", "vs-dark") # type: ignore
1818

1919
# The line to jump to in the editor.
20-
line: rx.Var[int] = rx.Var.create_safe(1, _var_is_string=False)
20+
line: rx.Var[int] = rx.Var.create(1)
2121

2222
# The height of the editor.
2323
width: rx.Var[str]
@@ -46,10 +46,10 @@ class MonacoEditor(MonacoComponent):
4646
value: rx.Var[str]
4747

4848
# Triggered when the editor value changes.
49-
on_change: rx.EventHandler[lambda e: [e]]
49+
on_change: rx.EventHandler[rx.event.passthrough_event_spec(str)]
5050

5151
# Triggered when the content is validated. (limited to some languages)
52-
on_validate: rx.EventHandler[lambda e: [e]]
52+
on_validate: rx.EventHandler[rx.event.passthrough_event_spec(str)]
5353

5454

5555
class DiffMonacoEditor(MonacoComponent):

monaco_demo/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
assets/external/
12
*.db
23
*.py[cod]
34
.web

monaco_demo/monaco_demo/monaco_demo.py

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
11
"""Welcome to Reflex! This file showcases the custom component in a basic app."""
22

3-
from pathlib import Path
43
from typing import Any
5-
from rxconfig import config
6-
7-
import reflex as rx
84

95
from reflex_monaco import monaco, monaco_diff
10-
from reflex.style import color_mode, set_color_mode
6+
7+
import reflex as rx
118

129
ORIGINAL_CONTENT = """
1310
# Reflex Monaco Editor Demo
@@ -35,12 +32,15 @@ class FileState(rx.State):
3532
original_content: str = ORIGINAL_CONTENT
3633
modified_content: str = ""
3734

35+
@rx.event
3836
def load_file_content(self):
3937
self.modified_content = self.original_content
4038

39+
@rx.event
4140
def on_change(self, value: str):
4241
self.modified_content = value
4342

43+
@rx.event
4444
def on_view_change(self, view: str):
4545
self.active_view = view
4646

@@ -76,7 +76,10 @@ def index() -> Any:
7676
return rx.vstack(
7777
rx.box(),
7878
rx.heading(
79-
"Monaco Editor Demo", size="9", align="center", text_decoration="underline"
79+
"Monaco Editor Demo",
80+
size="9",
81+
align="center",
82+
text_decoration="underline",
8083
),
8184
rx.code("pip install reflex-monaco"),
8285
rx.center(
@@ -98,7 +101,10 @@ def index() -> Any:
98101
spacing="6",
99102
width="100vw",
100103
height="100vh",
101-
), rx.color_mode.button(position="top-right", allow_system=True)
104+
), rx.color_mode.button(
105+
position="top-right",
106+
allow_system=True,
107+
)
102108

103109

104110
# Add state and page to the app.

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "reflex-monaco"
7-
version = "0.0.1"
7+
version = "0.0.2"
88
description = "A package wrapping Monaco Editor for Reflex"
99
readme = "README.md"
1010
license = { text = "Apache-2.0" }

0 commit comments

Comments
 (0)