Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/feature/client_data' into featur…
Browse files Browse the repository at this point in the history
…e/client_data
  • Loading branch information
Alyxion committed Apr 6, 2024
2 parents 84bc6ce + a4fe9cc commit 36f3b80
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 13 deletions.
9 changes: 3 additions & 6 deletions nicegui/elements/leaflet.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions nicegui/elements/leaflet.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""
Expand Down
8 changes: 5 additions & 3 deletions nicegui/elements/markdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,19 @@ export default {
this.ensure_codehilite_css();
if (this.use_mermaid) {
this.mermaid = (await import("mermaid")).default;
this.update(this.$el.innerHTML);
this.renderMermaid();
}
},
data() {
return {
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]] });
});
Expand Down
2 changes: 1 addition & 1 deletion nicegui/elements/markdown.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')))
Expand Down
2 changes: 1 addition & 1 deletion nicegui/elements/restructured_text.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')))
Expand Down

0 comments on commit 36f3b80

Please sign in to comment.