diff --git a/nicegui/elements/leaflet.js b/nicegui/elements/leaflet.js index 2bd5b41d1..2a81d6535 100644 --- a/nicegui/elements/leaflet.js +++ b/nicegui/elements/leaflet.js @@ -107,13 +107,10 @@ export default { clearInterval(connectInterval); }, 100); }, + updated() { + this.map?.setView(this.center, this.zoom); + }, methods: { - setCenter(center) { - this.map.panTo(center); - }, - setZoom(zoom) { - this.map.setZoom(zoom); - }, add_layer(layer, id) { const l = L[layer.type](...layer.args); l.id = id; diff --git a/nicegui/elements/leaflet.py b/nicegui/elements/leaflet.py index 750e9e17e..82104ab51 100644 --- a/nicegui/elements/leaflet.py +++ b/nicegui/elements/leaflet.py @@ -98,14 +98,14 @@ def set_center(self, center: Tuple[float, float]) -> None: if self._props['center'] == center: return self._props['center'] = center - self.run_method('setCenter', center) + self.update() def set_zoom(self, zoom: int) -> None: """Set the zoom level of the map.""" if self._props['zoom'] == zoom: return self._props['zoom'] = zoom - self.run_method('setZoom', zoom) + self.update() def remove_layer(self, layer: Layer) -> None: """Remove a layer from the map.""" diff --git a/nicegui/elements/markdown.js b/nicegui/elements/markdown.js index 24bcb9376..b5a28bc7a 100644 --- a/nicegui/elements/markdown.js +++ b/nicegui/elements/markdown.js @@ -4,7 +4,7 @@ export default { this.ensure_codehilite_css(); if (this.use_mermaid) { this.mermaid = (await import("mermaid")).default; - this.update(this.$el.innerHTML); + this.renderMermaid(); } }, data() { @@ -12,9 +12,11 @@ export default { mermaid: null, }; }, + updated() { + this.renderMermaid(); + }, methods: { - update(content) { - this.$el.innerHTML = content; + renderMermaid() { this.$el.querySelectorAll(".mermaid-pre").forEach(async (pre, i) => { await this.mermaid.run({ nodes: [pre.children[0]] }); }); diff --git a/nicegui/elements/markdown.py b/nicegui/elements/markdown.py index 029782d72..faeac23ee 100644 --- a/nicegui/elements/markdown.py +++ b/nicegui/elements/markdown.py @@ -34,7 +34,7 @@ def _handle_content_change(self, content: str) -> None: html = prepare_content(content, extras=' '.join(self.extras)) if self._props.get('innerHTML') != html: self._props['innerHTML'] = html - self.run_method('update', html) + self.update() @lru_cache(maxsize=int(os.environ.get('MARKDOWN_CONTENT_CACHE_SIZE', '1000'))) diff --git a/nicegui/elements/restructured_text.py b/nicegui/elements/restructured_text.py index cde94d7de..f941b9654 100644 --- a/nicegui/elements/restructured_text.py +++ b/nicegui/elements/restructured_text.py @@ -21,7 +21,7 @@ def _handle_content_change(self, content: str) -> None: html = prepare_content(content) if self._props.get('innerHTML') != html: self._props['innerHTML'] = html - self.run_method('update', html) + self.update() @lru_cache(maxsize=int(os.environ.get('RST_CONTENT_CACHE_SIZE', '1000')))