From f455c1213cdd06e3001992ca4d9d234179313261 Mon Sep 17 00:00:00 2001 From: Shrey Somaiya Date: Sat, 3 Dec 2022 16:13:22 +0100 Subject: [PATCH 1/2] update monaco-rust to yew 0.20 --- Cargo.toml | 2 +- src/yew/mod.rs | 7 ++----- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index e99d950..6539345 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -28,7 +28,7 @@ yew-components = ["api", "yew"] js-sys = "0.3" paste = "1.0" wasm-bindgen = "0.2" -yew = { version = "0.19", optional = true } +yew = { version = "0.20", features = ["csr"], optional = true } [dependencies.web-sys] version = "0.3" diff --git a/src/yew/mod.rs b/src/yew/mod.rs index 5913a83..121d22c 100644 --- a/src/yew/mod.rs +++ b/src/yew/mod.rs @@ -4,7 +4,7 @@ use crate::{ api::{CodeEditor as CodeEditorModel, TextModel}, sys::editor::IStandaloneEditorConstructionOptions, }; -use std::{cell::RefCell, mem, rc::Rc}; +use std::{cell::RefCell, rc::Rc}; use web_sys::HtmlElement; use yew::{html, html::Scope, Callback, Classes, Component, Context, Html, NodeRef, Properties}; @@ -31,7 +31,6 @@ pub struct CodeEditorProps, } @@ -60,14 +59,12 @@ impl Component for CodeEditor { } Self { - props: ctx.props().clone(), node_ref: NodeRef::default(), editor: None, } } - fn changed(&mut self, ctx: &Context) -> bool { - let old_props = mem::replace(&mut self.props, ctx.props().clone()); + fn changed(&mut self, ctx: &Context, old_props: &Self::Properties) -> bool { // these are the new values let CodeEditorProps { link, From 3aa33da93c119963a3a7aa5e5696442491b1fd3a Mon Sep 17 00:00:00 2001 From: Shrey Somaiya Date: Sat, 3 Dec 2022 16:13:32 +0100 Subject: [PATCH 2/2] update monaco-rust example to yew 0.20 --- examples/yew/Cargo.toml | 2 +- examples/yew/index.html | 8 +++++++- examples/yew/src/main.rs | 7 ++++--- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/examples/yew/Cargo.toml b/examples/yew/Cargo.toml index 2ed8775..070fcad 100644 --- a/examples/yew/Cargo.toml +++ b/examples/yew/Cargo.toml @@ -7,4 +7,4 @@ edition = "2018" [dependencies] monaco = { path = "../..", features = ["yew-components"] } wasm-bindgen = "0.2" -yew = "0.19" +yew = { version = "0.20", features = ["csr"] } diff --git a/examples/yew/index.html b/examples/yew/index.html index 539b3c0..c474ed9 100644 --- a/examples/yew/index.html +++ b/examples/yew/index.html @@ -9,8 +9,14 @@ import init from "./yew.js"; init(); + + - \ No newline at end of file + diff --git a/examples/yew/src/main.rs b/examples/yew/src/main.rs index c3bfaba..57f4ab7 100644 --- a/examples/yew/src/main.rs +++ b/examples/yew/src/main.rs @@ -9,6 +9,7 @@ fn get_options() -> CodeEditorOptions { .with_language("rust".to_owned()) .with_value(CONTENT.to_owned()) .with_builtin_theme(BuiltinTheme::VsDark) + .with_automatic_layout(true) } struct App { @@ -24,17 +25,17 @@ impl Component for App { } } - fn changed(&mut self, _context: &Context) -> bool { + fn changed(&mut self, _context: &Context, _old_props: &Self::Properties) -> bool { false } fn view(&self, _context: &Context) -> Html { html! { - + } } } fn main() { - yew::start_app::(); + yew::Renderer::::new().render(); }