Bläddra i källkod

#278 use innerHTML instead of content prop

Falko Schindler 2 år sedan
förälder
incheckning
29c3ffd20d
2 ändrade filer med 3 tillägg och 7 borttagningar
  1. 1 4
      nicegui/elements/markdown.js
  2. 2 3
      nicegui/elements/markdown.py

+ 1 - 4
nicegui/elements/markdown.js

@@ -1,7 +1,7 @@
 export default {
   template: `<div></div>`,
   mounted() {
-    this.update(this.content);
+    this.update(this.$el.innerHTML);
   },
   methods: {
     update(content) {
@@ -12,9 +12,6 @@ export default {
       });
     },
   },
-  props: {
-    content: String,
-  },
 };
 
 function decodeHtml(html) {

+ 2 - 3
nicegui/elements/markdown.py

@@ -12,7 +12,6 @@ register_component('markdown', __file__, 'markdown.js', ['lib/mermaid.min.js'])
 
 
 class Markdown(ContentElement):
-    CONTENT_PROP = 'content'
 
     def __init__(self, content: str = '', *, extras: List[str] = ['fenced-code-blocks', 'tables']) -> None:
         """Markdown Element
@@ -27,8 +26,8 @@ class Markdown(ContentElement):
 
     def on_content_change(self, content: str) -> None:
         html = prepare_content(content, extras=' '.join(self.extras))
-        if self._props.get('content') != html:
-            self._props['content'] = html
+        if self._props.get('innerHTML') != html:
+            self._props['innerHTML'] = html
             self.run_method('update', html)